-
Notifications
You must be signed in to change notification settings - Fork 5.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Response statusCode in node:http; undefined in Deno, 200 in Node #23970
Comments
vrugtehagel
changed the title
Response statusCode in node:http module undefined in Deno, 200 in Node
Response statusCode in node:http; undefined in Deno, 200 in Node
May 24, 2024
Here's a slightly simpler reproduction case: import { ServerResponse, ClientRequest } from 'node:http'
const request = new ClientRequest()
const response = new ServerResponse(request)
console.log(response.statusCode)
request.on('error', () => {}) I did try and set up Deno locally to see the impact of setting it to 200 by default, but I didn't quite manage to get the |
marvinhagemeister
added a commit
that referenced
this issue
May 26, 2024
Node sets the default HTTP response status code to 200 on the `ServerResponse`. We initialised it as `undefined` before which caused a problem with 11ty's dev server. Thanks to @vrugtehagel for reporting this issue and finding the correct fix as well 🎉 Fixes #23970
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This issue popped up when trying to use Eleventy with Deno (see 11ty/eleventy-dev-server#78). To reproduce a stripped-down version of the issue, consider the following script:
When running this script in node (e.g.
node script.js
), this logs200
. However, when running it in Deno (e.g.deno run -A script.js
), it logsundefined
. This causes the Eleventy bug mentioned above.After a little bit of digging, I did notice that Node seems to set statusCode to 200 by default. Deno seems to set it, but after the callback provided to
createServer()
has already run.A potential solution could be to default
statusCode
to 200 in Deno as well, though I have not checked for potential side effects as of yet.The text was updated successfully, but these errors were encountered: