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

"TypeError: Request3 is not a constructor" upgrading adapter-netlify from 76 to 77 - Resolved: esbuild does not work on Netlify, do not enable in netlify.toml or use netlify edge #7839

Closed
swyxio opened this issue Nov 28, 2022 · 7 comments · Fixed by swyxio/swyxkit#138

Comments

@swyxio
Copy link
Contributor

swyxio commented Nov 28, 2022

Describe the bug

I upgraded my SK version from 510 to 561 and adapter from
72 to 89 (swyxio/swyxkit@ffdd149) and it started reporting a TypeError: Request3 is not a constructor error:

image

(you can see the preview here https://app.netlify.com/sites/swyxkit/functions/render?scope=deploypreview:136) causing all renders to 500.

this doesnt happen in dev, only prod.

Reproduction

swyxio/swyxkit@ffdd149

i am debugging in swyxio/swyxkit#136

Logs

Nov 28, 12:38:24 PM: b5dfe38e ERROR  TypeError: Request3 is not a constructor
    at file:///var/task/.netlify/functions-internal/render.mjs:24273:22
    at new Promise (<anonymous>)
    at fetch3 (file:///var/task/.netlify/functions-internal/render.mjs:24272:10)
    at listContent (file:///var/task/.netlify/functions-internal/render.mjs:36534:23)
    at GET2 (file:///var/task/.netlify/functions-internal/render.mjs:36737:23)
    at render_endpoint (file:///var/task/.netlify/functions-internal/render.mjs:44730:29)
    at resolve (file:///var/task/.netlify/functions-internal/render.mjs:46610:29)
    at async respond (file:///var/task/.netlify/functions-internal/render.mjs:46520:23)
    at async fetch (file:///var/task/.netlify/functions-internal/render.mjs:46370:21)
    at async Object.fetch (file:///var/task/.netlify/functions-internal/render.mjs:46302:12)

System Info

"@histoire/plugin-svelte": "^0.11.7",
		"@playwright/test": "^1.28.1",
		"@sveltejs/adapter-auto": "1.0.0-next.89",
		"@sveltejs/kit": "^1.0.0-next.561",
		"@tailwindcss/typography": "^0.5.8",
		"@typescript-eslint/eslint-plugin": "^5.44.0",
		"@typescript-eslint/parser": "^5.44.0",
		"autoprefixer": "^10.4.13",
		"concurrently": "^7.6.0",
		"eslint": "^8.28.0",

Severity

annoyance

Additional Information

filing for others to find in future as i try to isolate the problem.

i am debugging in swyxio/swyxkit#136

@swyxio
Copy link
Contributor Author

swyxio commented Nov 28, 2022

at SK version 521 i am getting this issue Dynamic require of "fs" is not supported again #4079

https://app.netlify.com/sites/swyxkit/functions/render?scope=branch:bisectdeps

cc @PH4NTOMiki

image

@swyxio
Copy link
Contributor Author

swyxio commented Nov 28, 2022

ok as far as i know this is the status

Starting version: SK 510, Adapter auto 72
Latest version: SK 561, Adapter Auto 89

  • SK 541, Adapter Auto 79: broken
  • SK 541, Adapter Auto 75: broken
  • SK 541, Adapter Auto 73: broken
  • SK 541, Adapter Auto 72: working
  • SK 561, Adapter Auto 73: broken
  • SK 551, Adapter Auto 72: working
  • SK 561, Adapter Auto 72: working

References

@swyxio
Copy link
Contributor Author

swyxio commented Nov 28, 2022

ok the earliest bug i can find is

so the basic premise of SK itself not breaking is fine, just the adapter is curently broken.

now going to try to take a brand new SK project, add a fs/node fetch call, and deploy to netlify to see.

EDIT: nope, could not repro (https://github.com/sw-yx/repro-sveltekit-adapter-bug-72). i do think i should probably not use node-fetch anymore.

@swyxio swyxio changed the title "TypeError: Request3 is not a constructor" upgrading SvelteKit (from 510 to 561) + Netlify (cause unknown, investigating) "TypeError: Request3 is not a constructor" upgrading adapter-netlify from 76 to 77 - possibly incompatible with node fetch? Nov 28, 2022
@swyxio
Copy link
Contributor Author

swyxio commented Nov 28, 2022

ok turns out this is still a known bug - have to pin adapter netlify to 72 until this gets addressed #6440 cc @brittneypostma

@benmccann
Copy link
Member

The reason it's using esbuild is this line:

https://github.com/sw-yx/swyxkit/blob/ffdd14921ed058961d1b638735077fb26bbf8385/netlify.toml#L8

I recommend you remove that if you're having difficulty with esbuild. adatper-netlify will only use esbuild if you either set that option in netlify.toml or set edge: true in the adapter options

@swyxio
Copy link
Contributor Author

swyxio commented Nov 28, 2022

ahh thanks. its not yet 100% working for me (https://deploy-preview-138--swyxkit.netlify.app/welcome is mysteriously 404ing) but still pretty good! thank you!

@swyxio swyxio closed this as completed Nov 28, 2022
@swyxio swyxio changed the title "TypeError: Request3 is not a constructor" upgrading adapter-netlify from 76 to 77 - possibly incompatible with node fetch? "TypeError: Request3 is not a constructor" upgrading adapter-netlify from 76 to 77 - Resolved: esbuild does not work on Netlify, do not enable in netlify.toml or use netlify edge Nov 28, 2022
@filipwiniarski
Copy link

This one seems related: #12057

Having the same issue with edge functions enabled. Dynamic requires not working. I tried to write a polyfill onBuild plugin but couldn't make it work without breaking the the netlify edge function bundler 🤔

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 a pull request may close this issue.

3 participants