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: require toUSVString from fetch utils #1526

Closed
wants to merge 2 commits into from

Conversation

Kikobeats
Copy link
Contributor

Since util.toUSVString doesn't exist at node12, in this way the fallback implementation will be used.

Since `util.toUSVString` doesn't exist at node12, in this way the fallback implementation will be used.
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

why this change?

@Kikobeats
Copy link
Contributor Author

mainly to make webidl.converters.USVString addressable at Node12
https://github.com/vercel/edge-runtime/runs/7177696222?check_suite_focus=true#step%3A7%3A110=

@mcollina
Copy link
Member

mcollina commented Jul 4, 2022

I'm a bit lost. None of fetch should run on v12.

1 similar comment
@mcollina
Copy link
Member

mcollina commented Jul 4, 2022

I'm a bit lost. None of fetch should run on v12.

@Rich-Harris
Copy link

Presently, undici's package.json specifies 12.18 as the minimum version:

undici/package.json

Lines 99 to 101 in 5ca25c2

"engines": {
"node": ">=12.18"
},

In reality, it requires >16.9. Merging this PR wouldn't change that, since undici also uses Object.hasOwn. For that reason, I'd advocate updating the engines field and removing this line in favour of using the built-in util.toUSVString everywhere:

toUSVString: nodeUtil.toUSVString || ((val) => `${val}`),

@mcollina
Copy link
Member

mcollina commented Jul 7, 2022

In reality, it requires >16.9.

Can you articulate? We have our suite testing everything on 12, minus fetch - which is v16+ and clearly documented as such.

I'd be happy to work on whatever incompatibility there is as long as I get a reproduction.

@mcollina
Copy link
Member

mcollina commented Jul 7, 2022

I'd be happy to land this as long as we get a test that is failing on Node v12 - so we know we won't regress.

@Rich-Harris
Copy link

Sure — using Node 16.7:

const { Response } = require('undici');
new Response('ok');
/*
Uncaught TypeError: webidl.converters.USVString is not a function
    at Object.webidl.converters.XMLHttpRequestBodyInit (/[dir]/node_modules/undici/lib/fetch/response.js:516:30)
    at Object.webidl.converters.BodyInit (/[dir]/node_modules/undici/lib/fetch/response.js:554:28)
    at new Response (/[dir]/node_modules/undici/lib/fetch/response.js:138:32)
*/

Using Node 16.8:

const { Response } = require('undici');
new Response('ok');
/*
Uncaught TypeError: Object.hasOwn is not a function
    at Object.ResponseInit (/[dir]/node_modules/undici/lib/fetch/webidl.js:327:33)
    at new Response (/[dir]/node_modules/undici/lib/fetch/response.js:141:30)
*/

@mcollina
Copy link
Member

mcollina commented Jul 7, 2022

If I understand it correctly: the whole of fetch() is available only in Node.js v16+ but we do not specify which minor anywhere, causing the problem at hand (and the fact we broke people using Node.js v16.7 vs 16.9). Is this correct?

@ronag do we want to support v16.7 at all? Our tests are currently failing there.

The issue at the top was mentioning Node.js v12, which is what took me off guard.

@KhafraDev
Copy link
Member

do we want to support v16.7 at all?

Support should be easy enough, I don't see a reason not to. I'll work on a PR to support v16.5+ again.

@mcollina
Copy link
Member

mcollina commented Jul 8, 2022

Just add 16.5.0 to CI so we don't regress again.

@Kikobeats
Copy link
Contributor Author

closing since #1534 addressed it

@Kikobeats Kikobeats closed this Jul 11, 2022
@Kikobeats Kikobeats deleted the Kikobeats-patch-3 branch July 11, 2022 13: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

4 participants