@nxtedition/lib 26.0.9 → 26.0.10

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.
Files changed (3) hide show
  1. package/cache.js +8 -3
  2. package/http.js +11 -8
  3. package/package.json +1 -1
package/cache.js CHANGED
@@ -104,9 +104,14 @@ export class AsyncCache {
104
104
  )
105
105
  this.#delQuery = this.#db.prepare(`DELETE FROM cache WHERE key = ?`)
106
106
  } catch (err) {
107
- if (n > 128 || !/locked|busy/i.test(err?.message)) {
108
- throw err
109
- }
107
+ this.#db?.close()
108
+ this.#db = null
109
+
110
+ this.#getQuery = null
111
+ this.#setQuery = null
112
+ this.#delQuery = null
113
+
114
+ process.emitWarning(err)
110
115
  }
111
116
  }
112
117
  }
package/http.js CHANGED
@@ -75,7 +75,7 @@ export class Context {
75
75
  return this.#req.target
76
76
  }
77
77
 
78
- this.#target ??= requestTarget(this.#req)
78
+ this.#target ??= Object.freeze(requestTarget(this.#req))
79
79
 
80
80
  if (!this.#target) {
81
81
  throw new createError.BadRequest('invalid url')
@@ -89,13 +89,10 @@ export class Context {
89
89
  return this.#req.query
90
90
  }
91
91
 
92
- this.#target ??= requestTarget(this.#req)
93
- this.#query ??=
94
- this.#target.search.length > 1
95
- ? Object.freeze(querystring.parse(this.#target.search.slice(1)))
96
- : {}
92
+ const search = this.target.search
97
93
 
98
- return this.#query
94
+ return (this.#query ??=
95
+ search.length > 1 ? Object.freeze(querystring.parse(search.slice(1))) : {})
99
96
  }
100
97
 
101
98
  get userAgent() {
@@ -373,7 +370,13 @@ export class IncomingMessage extends http.IncomingMessage {
373
370
  this.#target = undefined
374
371
  }
375
372
 
376
- return (this.#target ??= requestTarget(this))
373
+ this.#target ??= Object.freeze(requestTarget(this))
374
+
375
+ if (!this.#target) {
376
+ throw new createError.BadRequest('invalid url')
377
+ }
378
+
379
+ return this.#target
377
380
  }
378
381
 
379
382
  get query() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "26.0.9",
3
+ "version": "26.0.10",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",