dsh-unlag 1.9.57 → 1.9.59
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 +22 -13
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -64,7 +64,6 @@ const CODE_STAMP = (() => {
|
|
|
64
64
|
return 'unknown'
|
|
65
65
|
}
|
|
66
66
|
})()
|
|
67
|
-
let logWrites = 0
|
|
68
67
|
/** Tests point this at a scratch file, so a test run leaves the live log readable. */
|
|
69
68
|
const logTarget = () => process.env.DSH_UNLAG_LOG ?? LOG_PATH
|
|
70
69
|
/** Survives a module replacement, so a reload cannot leave a second watcher behind. */
|
|
@@ -261,17 +260,17 @@ function ensureLogDir(target) {
|
|
|
261
260
|
function log(line) {
|
|
262
261
|
try {
|
|
263
262
|
const target = logTarget()
|
|
264
|
-
// A file that only grows eventually costs the app its own memory budget: every 200 lines the
|
|
265
|
-
// size is checked once, and a log past the cap starts over instead of growing without end.
|
|
266
|
-
logWrites += 1
|
|
267
|
-
if (logWrites % 200 === 1) {
|
|
268
|
-
try {
|
|
269
|
-
if (statSync(target).size > LOG_MAX_BYTES) writeFileSync(target, '')
|
|
270
|
-
} catch {
|
|
271
|
-
/* a missing or unreadable log is created by the append below */
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
263
|
const text = `${new Date().toISOString()} ${oneLine(line)}\n`
|
|
264
|
+
/**
|
|
265
|
+
* A file that only grows eventually costs the app its own memory budget, and a burst of lines
|
|
266
|
+
* can land between two periodic checks: the size is read before every write and the whole
|
|
267
|
+
* line has to fit, so the file never passes the cap even for one event.
|
|
268
|
+
*/
|
|
269
|
+
try {
|
|
270
|
+
if (statSync(target).size + Buffer.byteLength(text) > LOG_MAX_BYTES) writeFileSync(target, '')
|
|
271
|
+
} catch {
|
|
272
|
+
/* a missing or unreadable log is created by the append below */
|
|
273
|
+
}
|
|
275
274
|
try {
|
|
276
275
|
appendFileSync(target, text)
|
|
277
276
|
} catch {
|
|
@@ -1270,7 +1269,12 @@ function serveBundlesAtCurrentRevision(ctx) {
|
|
|
1270
1269
|
* from. Only when it has nothing is the same request tried at the revision of the plugin it
|
|
1271
1270
|
* names, because a chunk is served at its entry's revision and nowhere else.
|
|
1272
1271
|
*/
|
|
1273
|
-
|
|
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 {}
|
|
1274
1278
|
// Same reason as the handler shape below: a rejection here is unhandled and ends the process.
|
|
1275
1279
|
let retargeted = null
|
|
1276
1280
|
try {
|
|
@@ -1316,7 +1320,12 @@ function serveBundlesAtCurrentRevision(ctx) {
|
|
|
1316
1320
|
* first, so the served document and the chunks it later asks for are one generation.
|
|
1317
1321
|
*/
|
|
1318
1322
|
const wrapped = async (req, res) => {
|
|
1319
|
-
|
|
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 {}
|
|
1320
1329
|
// Reading the table can throw while the plugin set is being swapped. This runs inside an async
|
|
1321
1330
|
// route handler, where a rejection is an unhandled one and takes the whole app with it, so the
|
|
1322
1331
|
// failure has to end here: answer the request as the table left it and say why in the log.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-unlag",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.59",
|
|
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",
|