dsh-unlag 1.9.58 → 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 +29 -8
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1269,7 +1269,12 @@ function serveBundlesAtCurrentRevision(ctx) {
|
|
|
1269
1269
|
* from. Only when it has nothing is the same request tried at the revision of the plugin it
|
|
1270
1270
|
* names, because a chunk is served at its entry's revision and nowhere else.
|
|
1271
1271
|
*/
|
|
1272
|
-
|
|
1272
|
+
// Reading the address is the first thing that runs, and a request object that cannot answer it
|
|
1273
|
+
// would reject this async handler before any guard below: it is read as no address instead.
|
|
1274
|
+
let url = ''
|
|
1275
|
+
try {
|
|
1276
|
+
url = String(request?.url ?? '')
|
|
1277
|
+
} catch {}
|
|
1273
1278
|
// Same reason as the handler shape below: a rejection here is unhandled and ends the process.
|
|
1274
1279
|
let retargeted = null
|
|
1275
1280
|
try {
|
|
@@ -1315,7 +1320,12 @@ function serveBundlesAtCurrentRevision(ctx) {
|
|
|
1315
1320
|
* first, so the served document and the chunks it later asks for are one generation.
|
|
1316
1321
|
*/
|
|
1317
1322
|
const wrapped = async (req, res) => {
|
|
1318
|
-
|
|
1323
|
+
// Same as the resource shape: an address that cannot be read is no address. Throwing here would
|
|
1324
|
+
// reject the handler the server is awaiting, and a rejection nobody catches ends the process.
|
|
1325
|
+
let originalUrl = ''
|
|
1326
|
+
try {
|
|
1327
|
+
originalUrl = String(req?.url ?? '')
|
|
1328
|
+
} catch {}
|
|
1319
1329
|
// Reading the table can throw while the plugin set is being swapped. This runs inside an async
|
|
1320
1330
|
// route handler, where a rejection is an unhandled one and takes the whole app with it, so the
|
|
1321
1331
|
// failure has to end here: answer the request as the table left it and say why in the log.
|
|
@@ -1325,10 +1335,22 @@ function serveBundlesAtCurrentRevision(ctx) {
|
|
|
1325
1335
|
} catch (error) {
|
|
1326
1336
|
log(`cannot read the plugin table for a bundle request: ${error?.message ?? error}`)
|
|
1327
1337
|
}
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
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
|
|
1331
1346
|
let canHold = true
|
|
1347
|
+
try {
|
|
1348
|
+
realWriteHead = res.writeHead
|
|
1349
|
+
realEnd = res.end
|
|
1350
|
+
realWriteRef = res.write
|
|
1351
|
+
} catch {
|
|
1352
|
+
canHold = false
|
|
1353
|
+
}
|
|
1332
1354
|
const ask = async (url) => {
|
|
1333
1355
|
let held = null
|
|
1334
1356
|
let body
|
|
@@ -1348,7 +1370,6 @@ function serveBundlesAtCurrentRevision(ctx) {
|
|
|
1348
1370
|
* also owes the caller the callbacks it passed: dropping one would leave a handler that waits
|
|
1349
1371
|
* for the flush awaiting forever, and the answer after it would never run.
|
|
1350
1372
|
*/
|
|
1351
|
-
const realWrite = res.write
|
|
1352
1373
|
const answerCallback = (args) => {
|
|
1353
1374
|
for (let at = args.length - 1; at >= 0; at -= 1) {
|
|
1354
1375
|
if (typeof args[at] === 'function') {
|
|
@@ -1375,14 +1396,14 @@ function serveBundlesAtCurrentRevision(ctx) {
|
|
|
1375
1396
|
*/
|
|
1376
1397
|
if (canHold) {
|
|
1377
1398
|
try {
|
|
1378
|
-
if (typeof
|
|
1399
|
+
if (typeof realWriteRef === 'function') {
|
|
1379
1400
|
res.write = (chunk, ...rest) => {
|
|
1380
1401
|
if (held !== null) {
|
|
1381
1402
|
if (typeof chunk === 'string' || Buffer.isBuffer(chunk)) parts.push(Buffer.from(chunk))
|
|
1382
1403
|
answerCallback(rest)
|
|
1383
1404
|
return true
|
|
1384
1405
|
}
|
|
1385
|
-
return
|
|
1406
|
+
return realWriteRef.call(res, chunk, ...rest)
|
|
1386
1407
|
}
|
|
1387
1408
|
}
|
|
1388
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",
|