Skip to content
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

fix(ext/node): fix whatwg url formatting #19146

Merged
merged 3 commits into from
May 17, 2023

Conversation

kt3k
Copy link
Member

@kt3k kt3k commented May 16, 2023

This PR fixes the bug of url.format of node:url module (which affects the execution of remix)

Currently the following script prints http:https://localhost:3000:3000/:

import url from "node:url";
console.log(url.format(new URL("http:https://localhost:3000")));

This PR fixes the above bug and it now prints http:https://localhost:3000/. (This PR also implements unicode option handling of url.format)

@kt3k kt3k requested a review from bartlomieju May 16, 2023 13:02
@bartlomieju
Copy link
Member

@kt3k any chance this could be related to bartlomieju/vite-deno-example#7?

@kt3k
Copy link
Member Author

kt3k commented May 16, 2023

In the case of remix, the stack trace look like the below:

Remix App Server started at http:https://localhost:3000 (http:https://10.2.10.173:3000)
TypeError: Invalid URL: 'http:https://localhost:3000:3000/'
    at getSerialization (ext:deno_url/00_url.js:89:11)
    at new URL (ext:deno_url/00_url.js:359:27)
    at requestHandler (file:https:///Users/kt3k/tmp/y/node_modules/.deno/@[email protected]/node_modules/@remix-run/server-runtime/dist/server.js:32:15)
    at file:https:///Users/kt3k/tmp/y/node_modules/.deno/@[email protected]/node_modules/@remix-run/express/dist/server.js:39:28
    at eventLoopTick (ext:core/01_core.js:181:11)
Terminating Deno.serve loop due to unexpected error TypeError: Cannot read properties of undefined (reading 'status')
    at ext:deno_http/00_serve.js:544:26
    at eventLoopTick (ext:core/01_core.js:188:13)

The actual invalid url (http:https://localhost:3000:3000/) is passed to URL constructor. So I guess it might be slightly different issue.

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kt3k kt3k merged commit 243d9c8 into denoland:main May 17, 2023
10 checks passed
@kt3k kt3k deleted the fix-node-url-format-whatwg branch May 17, 2023 05:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants