Skip to content

Commit 011f3b5

Browse files
committed
req.node -> req.runtime.node
1 parent 59ce000 commit 011f3b5

5 files changed

Lines changed: 7 additions & 7 deletions

File tree

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/server/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ The main server request handler invoked on every request.
207207
Use this to integrate into your existing Node.js server.
208208

209209
This handler converts `http.IncomingMessage`/`http.ServerResponse` to `Request`/`Response`.
210-
You can still access the Node.js versions via `req.node.req`/`req.node.res` in the hooks.
210+
You can still access the Node.js versions via `req.runtime.node.req`/`req.runtime.node.res` in the hooks.
211211

212212
#### `server.handleWeb(req: Request)`
213213

packages/server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"debug": "^4.3.4",
2626
"lodash.throttle": "^4.1.1",
2727
"set-cookie-parser": "^2.7.1",
28-
"srvx": "^0.8.2"
28+
"srvx": "~0.8.2"
2929
},
3030
"devDependencies": {
3131
"@types/debug": "^4.1.12",

packages/server/src/server.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,16 @@ export class Server extends EventEmitter {
130130
return this.handler(req)
131131
}
132132

133-
private async handler(req: Request) {
133+
private async handler(req: Request | ServerRequest) {
134134
const context = this.createContext()
135135
const headers = new Headers()
136136

137137
// Special case on the Node.js runtime,
138138
// We handle gracefully request errors such as disconnects or timeouts.
139139
// This is important to avoid memory leaks and ensure that the server can
140140
// handle subsequent requests without issues.
141-
if ('node' in req && req.node) {
142-
const nodeReq = (req.node as {req: http.IncomingMessage}).req
141+
if ((req as ServerRequest)?.runtime?.node) {
142+
const nodeReq = (req as ServerRequest).runtime?.node?.req!
143143
nodeReq.once('error', () => {
144144
context.abort()
145145
})

packages/server/src/test/Server.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ describe('Server', () => {
443443
datastore: new FileStore({directory}),
444444
async onIncomingRequest(req) {
445445
// @ts-expect-error fine
446-
if (req?.node?.req?.user?.username === 'admin') {
446+
if (req?.runtime?.node?.req?.user?.username === 'admin') {
447447
done()
448448
} else {
449449
done(new Error('user data should be preserved in onIncomingRequest'))

0 commit comments

Comments
 (0)