dsh-unlag 1.9.59 → 1.9.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +17 -6
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1335,10 +1335,22 @@ function serveBundlesAtCurrentRevision(ctx) {
|
|
|
1335
1335
|
} catch (error) {
|
|
1336
1336
|
log(`cannot read the plugin table for a bundle request: ${error?.message ?? error}`)
|
|
1337
1337
|
}
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1338
|
+
/**
|
|
1339
|
+
* Reading the response is the other thing that runs before any guard. A response that cannot
|
|
1340
|
+
* answer a read is treated as one that cannot be held: the table's answer goes through, and a
|
|
1341
|
+
* throw here would reject the handler the server is awaiting.
|
|
1342
|
+
*/
|
|
1343
|
+
let realWriteHead
|
|
1344
|
+
let realEnd
|
|
1345
|
+
let realWriteRef
|
|
1341
1346
|
let canHold = true
|
|
1347
|
+
try {
|
|
1348
|
+
realWriteHead = res.writeHead
|
|
1349
|
+
realEnd = res.end
|
|
1350
|
+
realWriteRef = res.write
|
|
1351
|
+
} catch {
|
|
1352
|
+
canHold = false
|
|
1353
|
+
}
|
|
1342
1354
|
const ask = async (url) => {
|
|
1343
1355
|
let held = null
|
|
1344
1356
|
let body
|
|
@@ -1358,7 +1370,6 @@ function serveBundlesAtCurrentRevision(ctx) {
|
|
|
1358
1370
|
* also owes the caller the callbacks it passed: dropping one would leave a handler that waits
|
|
1359
1371
|
* for the flush awaiting forever, and the answer after it would never run.
|
|
1360
1372
|
*/
|
|
1361
|
-
const realWrite = res.write
|
|
1362
1373
|
const answerCallback = (args) => {
|
|
1363
1374
|
for (let at = args.length - 1; at >= 0; at -= 1) {
|
|
1364
1375
|
if (typeof args[at] === 'function') {
|
|
@@ -1385,14 +1396,14 @@ function serveBundlesAtCurrentRevision(ctx) {
|
|
|
1385
1396
|
*/
|
|
1386
1397
|
if (canHold) {
|
|
1387
1398
|
try {
|
|
1388
|
-
if (typeof
|
|
1399
|
+
if (typeof realWriteRef === 'function') {
|
|
1389
1400
|
res.write = (chunk, ...rest) => {
|
|
1390
1401
|
if (held !== null) {
|
|
1391
1402
|
if (typeof chunk === 'string' || Buffer.isBuffer(chunk)) parts.push(Buffer.from(chunk))
|
|
1392
1403
|
answerCallback(rest)
|
|
1393
1404
|
return true
|
|
1394
1405
|
}
|
|
1395
|
-
return
|
|
1406
|
+
return realWriteRef.call(res, chunk, ...rest)
|
|
1396
1407
|
}
|
|
1397
1408
|
}
|
|
1398
1409
|
if (typeof realEnd === 'function') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-unlag",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.60",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A press applies plugin edits right away and brings a laggy interface back; automatic reloading stays off unless you turn it on, so the press is the only trigger, and nothing restarts.",
|
|
6
6
|
"license": "MIT",
|