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

🐛 BUG: [ERROR] service core:user:worker: Uncaught TypeError: Invalid URL string. #7265

Closed
niklasfjeldberg opened this issue Nov 15, 2024 · 10 comments
Assignees
Labels
bug Something that isn't working

Comments

@niklasfjeldberg
Copy link

Which Cloudflare product(s) does this pertain to?

Pages

What version(s) of the tool(s) are you using?

3.87.0

What version of Node are you using?

22.11.0

What operating system and version are you using?

Linux (WSL)

Describe the Bug

Observed behavior

I have made a website with Nuxt 3 (v3.14.159) and when I try to run the website locally as CF Pages (also the same error on Cloudflare Pages own servers) I get the following error: [ERROR] service core:user:worker: Uncaught TypeError: Invalid URL string

The error log is not helpful for me as I am unable to locate and find out whats wrong.

Expected behavior

It should not give an error.

Steps to reproduce

I am not able to provide a public repo or minimal working code, but can provide the repo to the devs here. If no one else have any helpful advice.

This is how my wrangler.toml file looks like:

compatibility_date="2024-09-02"
compatibility_flags=["nodejs_compat_v2"]

Commands used to build and start the server:

"build:cf": "nuxi build --preset=cloudflare_pages",
"start:cf": "wrangler pages dev ./dist", 

Please provide a link to a minimal reproduction

No response

Please provide any relevant error logs

> wrangler pages dev ./dist


 ⛅️ wrangler 3.87.0
-------------------

Attaching additional modules:
┌──────────────────────────────────────────────────┬──────┬─────────────┐
│ Name                                             │ Type │ Size        │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/_/error-500.mjs                           │ esm  │ 4.77 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/_/getEventID.mjs                          │ esm  │ 15.62 KiB   │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/_/v4.mjs                                  │ esm  │ 1.12 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/Card-KF4IrUo8.mjs                   │ esm  │ 2.97 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/CountDown-styles-1.mjs-CH0ZZzdk.mjs │ esm  │ 0.89 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/CountDown-styles.BKj4Xvhz.mjs       │ esm  │ 0.42 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/CountDown-styles.CGwOQvHt.mjs       │ esm  │ 0.42 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/H1-v-IQiJYp.mjs                     │ esm  │ 1.00 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/Input-CDCWq5lS.mjs                  │ esm  │ 14.66 KiB   │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/Issues-CPd3JfLI.mjs                 │ esm  │ 1.49 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/ModalSuccess-ChXYYXf3.mjs           │ esm  │ 3.67 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/P-CMudS6fj.mjs                      │ esm  │ 1.00 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/PrivacyPolicy-styles.B3HcKi4X.mjs   │ esm  │ 0.42 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/PrivacyPolicy-styles.CJByC3os.mjs   │ esm  │ 0.41 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/Progress-styles-1.mjs-4EHqM8-a.mjs  │ esm  │ 4.12 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/Progress-styles.DTk4nyp5.mjs        │ esm  │ 0.42 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/Progress-styles.Zz7EdMwu.mjs        │ esm  │ 0.42 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/SalesTerms-styles.Bc2TFfJX.mjs      │ esm  │ 0.41 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/SalesTerms-styles.ee9TT1Zh.mjs      │ esm  │ 0.42 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/Toggle-Dk5b8jBa.mjs                 │ esm  │ 8.01 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/access-D0SCS43Z.mjs                 │ esm  │ 0.74 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/app-styles.Czy36uwh.mjs             │ esm  │ 0.41 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/app-styles.DrXHc5d0.mjs             │ esm  │ 0.42 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/client.manifest.mjs                 │ esm  │ 10.98 KiB   │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/entry-styles-3.mjs-7c6USuvS.mjs     │ esm  │ 0.83 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/entry-styles-4.mjs-WtlOUhWb.mjs     │ esm  │ 0.83 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/entry-styles-5.mjs-7RKY_Lto.mjs     │ esm  │ 0.67 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/entry-styles.D0A2Nx8i.mjs           │ esm  │ 90.92 KiB   │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/error-404-d8fPDqmQ.mjs              │ esm  │ 4.67 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/error-404-styles-1.mjs-jZp64Wmo.mjs │ esm  │ 4.15 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/error-404-styles.DuH9qVr6.mjs       │ esm  │ 0.41 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/error-404-styles.nUIDPVS_.mjs       │ esm  │ 0.41 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/error-500-Bc2OhjVV.mjs              │ esm  │ 4.27 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/error-500-styles-1.mjs-BnZcnvru.mjs │ esm  │ 2.50 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/error-500-styles.BtK1-mlq.mjs       │ esm  │ 0.41 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/error-500-styles.CUTndPYP.mjs       │ esm  │ 0.41 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/form-D9drBLMq.mjs                   │ esm  │ 1.96 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/gi-DXbeBcwb.mjs                     │ esm  │ 34.65 KiB   │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/index-BG29HprR.mjs                  │ esm  │ 2.35 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/index-BtZC_Xak.mjs                  │ esm  │ 1.11 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/index-CdZmgY_X.mjs                  │ esm  │ 14.57 KiB   │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/min-side-DCS1vJDq.mjs               │ esm  │ 93.56 KiB   │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/server.mjs                          │ esm  │ 198.73 KiB  │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/ssn-CwSdRLNj.mjs                    │ esm  │ 9.07 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/styles.mjs                          │ esm  │ 3.19 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/takk-C-8xhe0l.mjs                   │ esm  │ 5.00 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/virtual_public-D7V6QAYH.mjs         │ esm  │ 0.69 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/build/workshop-Dyp3EBhU.mjs               │ esm  │ 11.80 KiB   │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/nitro/nitro.mjs                           │ esm  │ 432.15 KiB  │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/routes/api/_id/segment-count.get.mjs      │ esm  │ 0.61 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/routes/api/donate-success.post.mjs        │ esm  │ 0.83 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/routes/api/donate.post.mjs                │ esm  │ 0.75 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/routes/api/event-sign-up.post.mjs         │ esm  │ 1.56 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/routes/api/privacy-policy.get.mjs         │ esm  │ 0.50 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/routes/api/sales-terms.get.mjs            │ esm  │ 0.49 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/routes/api/sign.post.mjs                  │ esm  │ 1.10 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/routes/api/slack-message.post.mjs         │ esm  │ 0.56 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/routes/api/ssn.post.mjs                   │ esm  │ 1.17 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/routes/renderer.mjs                       │ esm  │ 136.36 KiB  │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ chunks/virtual/_virtual_spa-template.mjs         │ esm  │ 0.33 KiB    │
├──────────────────────────────────────────────────┼──────┼─────────────┤
│ Total (60 modules)                               │      │ 1138.79 KiB │
└──────────────────────────────────────────────────┴──────┴─────────────┘
✨ Compiled Worker successfully
✨ Parsed 0 valid redirect rules.
✨ Parsed 4 valid header rules.
[wrangler:inf] Ready on http://localhost:8788
⎔ Starting local server...
✘ [ERROR] service core:user:worker: Uncaught TypeError: Invalid URL string.

    at null.<anonymous> (xjrypum68b8.js:37308:23) in createHook
    at null.<anonymous> (xjrypum68b8.js:37481:96)



✘ [ERROR] The Workers runtime failed to start. There is likely additional logging output above.
@niklasfjeldberg niklasfjeldberg added the bug Something that isn't working label Nov 15, 2024
@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Nov 15, 2024
@thescientist13
Copy link

thescientist13 commented Nov 17, 2024

Getting a similar error when deploying a function to Cloudflare

19:23:54.615 | Found Functions directory at /functions. Uploading.
-- | --
19:23:54.622 | ⛅️ wrangler 3.76.0
19:23:54.622 | -------------------
19:23:55.871 | ✨ Compiled Worker successfully
19:23:55.917 | Validating asset output directory
19:23:57.554 | Deploying your site to Cloudflare's global network...
19:24:01.343 | Uploading... (19/19)
19:24:01.344 | ✨ Success! Uploaded 0 files (19 already uploaded) (0.46 sec)
19:24:01.344 |  
19:24:01.687 | ✨ Upload complete!
19:24:03.367 | Success: Assets published!
19:24:05.004 | Error: Failed to publish your Function. Got error: Uncaught TypeError: Invalid URL string.   at functionsWorker-0.8204575732284836.js:46232:25 in products/products.route.js   at functionsWorker-0.8204575732284836.js:5:59 in __init   at functionsWorker-0.8204575732284836.js:46268:5 in products/index.js   at functionsWorker-0.8204575732284836.js:5:59 in __init   at functionsWorker-0.8204575732284836.js:46277:5 in ../../../pages/build_tool/js/.wrangler/tmp/pages-u2mHuu/functionsRoutes-0.967709881045554.mjs   at functionsWorker-0.8204575732284836.js:5:59 in __init   at functionsWorker-0.8204575732284836.js:46298:1

My hunch is that the issue is related to usage of new URL + import.meta.url in my code, since I had a similar issue when deploying the exact same code output to Netlify, which also uses esbuild and has a known issue with processing import.meta.url, and I understand that Wrangler is also using esbuild.


However, unlike Netlify, there seems to be no way to opt-out of bundling with esbuild that I can find, other than through the CLI and the --no-bundle flag, which I'm not using (just using the git integration + functions/ directory).

I would love to be able to do through wrangler.toml, but it seems like that is not supported - #6434 ? For example, with Netlify I can do this in their netlify.toml and nothing will get processed.

[build.processing]
  skip_processing = true

The same code works fine on Vercel using their Build Output API.

(I'm basically testing the same code sample across all hosting providers)

@CarmenPopoviciu
Copy link
Contributor

hi @niklasfjeldberg and @thescientist13,

Thank you for raising this issue with us. Any chance one of you can provide us with some minimal reproduction 🙏 ? I'm not able to reproduce the error you're seeing locally, so that would really help us narrow things down

<3

@CarmenPopoviciu CarmenPopoviciu added the awaiting reporter response Needs clarification or followup from OP label Nov 18, 2024
@thescientist13
Copy link

thescientist13 commented Nov 18, 2024

Hey @CarmenPopoviciu 👋

Here's a repro repo I made that has a couple minimal functions that work
https://github.com/thescientist13/cloudflare-workers-demo
https://cloudflare-workers-demo-4fb.pages.dev/

And then in this PR I added another function using new URL + import.meta.url that shows the error above when it builds on Cloudflare
thescientist13/cloudflare-workers-demo#1

Hope that helps, and let me know if you need any more info.

@CarmenPopoviciu
Copy link
Contributor

ah, this is fantastic!! thank you so much @thescientist13 🙏 . Going to have a look at this tomorrow morning, and see what's going on

@CarmenPopoviciu CarmenPopoviciu self-assigned this Nov 18, 2024
@CarmenPopoviciu CarmenPopoviciu added the awaiting Cloudflare response Awaiting response from workers-sdk maintainer team label Nov 18, 2024
@emily-shen emily-shen removed the awaiting reporter response Needs clarification or followup from OP label Nov 28, 2024
@CarmenPopoviciu
Copy link
Contributor

hi @thescientist13

My apologies for taking so long to reply. I did look into it and I can confirm that I am seeing the same when following your reproduction steps (thx again for that amazing repro ♥️ !!). Furthermore, I want to confirm, for posterity reasons, that this is not just a Pages issue. I am seeing the same error in Workers proper as well.

At first, I too thought it might be an esbuild issue based on evanw/esbuild#3039. But after digging into it further it actually turned out that workerd - the runtime that powers CF Workers - doesn't yet support import.meta. This is currently being worked on, but unfortunately there is no exact timeline available at the moment as to when it will be generally available.

I'm afraid that for now there's not much more I can advise here, other than wait until this feature is implemented in the runtime :(

@CarmenPopoviciu CarmenPopoviciu removed the awaiting Cloudflare response Awaiting response from workers-sdk maintainer team label Dec 2, 2024
@CarmenPopoviciu
Copy link
Contributor

oh, and one more thing...

there seems to be no way to opt-out of bundling with esbuild that I can find ((just using the git integration + functions/ directory))

for this setup specifically, it is indeed not possible to opt out of esbuild. But generally speaking, opting out of esbuild is complicated for Pages, and not something we provide a public contract for atm.

Workers on the other hand do support that via Custom Builds

@CarmenPopoviciu
Copy link
Contributor

I'm sorry I couldn't help more for now. Let me know if you have any follow-up questions. In the meanwhile I'll go ahead and close this issue, since the relevant body of work is not tracked in this repository. Once that work lands in workerd, import.meta should be available out of the box for both Workers and Pages

♥️

@github-project-automation github-project-automation bot moved this from Untriaged to Done in workers-sdk Dec 2, 2024
@thescientist13
Copy link

thescientist13 commented Dec 2, 2024

Thanks for taking a look @CarmenPopoviciu !

Workers on the other hand do support that via Custom Builds

As far as I can tell, I could only find a way to do that via the CLI. Is there anyway to do that with a wrangler.toml? I had referenced this issue which seems to indicate it is not? Not sure if you can confirm or not.

I'll go ahead and close this issue, since the relevant body of work is not tracked in this repository. Once that work lands in workerd, import.meta should be available out of the box for both Workers and Pages

Ah bummer. Is there an issue to follow along with that does track this work?

edit: I think I found the relevant issue - cloudflare/workerd#2963

@CarmenPopoviciu
Copy link
Contributor

CarmenPopoviciu commented Dec 3, 2024

hi @thescientist13,

Is there anyway to do that with a wrangler.toml

If you mean for Pages, unfortunately the answer is no. wrangler.toml does not support no_bundle for Pages atm, and I am not aware of any immediate plans to implement it. Having said that though, this would be a trivial change to make, and since wrangler dev supports it, I can abs understand why folks would want parity between dev, pages dev, the config file and CLI args. Let me bring this up to my team and see if there's anything strongly speaking against it. If not, I can put a PR up in no time. That feature request you linked in your message is the right place to keep track of the work

Is there an issue to follow along with that does track this work?

That issue you linked in there, is precisely the one!

♥️

@thescientist13
Copy link

Great, thanks for all your help @CarmenPopoviciu 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that isn't working
Projects
Status: Done
Development

No branches or pull requests

4 participants