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

refactor(dev): attach worker reload error as cause #2651

Merged
merged 4 commits into from
Sep 20, 2024
Merged

Conversation

tobiasdiez
Copy link
Contributor

πŸ”— Linked issue

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Improve the error message to include more details on where the error happens.

Before

[worker reload] Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'd:'
    at throwIfUnsupportedURLScheme (node:internal/modules/esm/load:228:11)
    at defaultLoad (node:internal/modules/esm/load:110:3)
    at ModuleLoader.load (node:internal/modules/esm/loader:567:13)
    at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:442:56)
    at new ModuleJob (node:internal/modules/esm/module_job:76:27)
    at #createModuleJob (node:internal/modules/esm/loader:455:17)
    at ModuleLoader.getJobFromResolveResult (node:internal/modules/esm/loader:266:34)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:247:17)

After

[worker reload] Error: [worker init] D:/Programming/JabRefOnline/.nuxt/dev/index.mjs failed
    at Worker.<anonymous> (file:///D:/Programming/JabRefOnline/node_modules/.pnpm/[email protected]_patch_hash=i7fsivvt52bwxcdhgprlrzxqpy_@[email protected]_@[email protected][email protected]/node_modules/nitropack/dist/chunks/server.mjs:210:22)
    at Object.onceWrapper (node:events:635:26)
    at Worker.emit (node:events:520:28)
    at [kOnErrorMessage] (node:internal/worker:326:10)
    at [kOnMessage] (node:internal/worker:337:37)
    at MessagePort.<anonymous> (node:internal/worker:232:57)
    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:816:20)
    at MessagePort.<anonymous> (node:internal/per_context/messageport:23:28)
    at MessagePort.callbackTrampoline (node:internal/async_hooks:130:17)
    at [kOnExit] (node:internal/worker:303:5) {
  [cause]: Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'd:'  
      at throwIfUnsupportedURLScheme (node:internal/modules/esm/load:228:11)
      at defaultLoad (node:internal/modules/esm/load:110:3)
      at ModuleLoader.load (node:internal/modules/esm/loader:567:13)
      at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:442:56)
      at new ModuleJob (node:internal/modules/esm/module_job:76:27)
      at #createModuleJob (node:internal/modules/esm/loader:455:17)
      at ModuleLoader.getJobFromResolveResult (node:internal/modules/esm/loader:266:34)
      at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:247:17) {
    code: 'ERR_UNSUPPORTED_ESM_URL_SCHEME'

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@pi0
Copy link
Member

pi0 commented Aug 12, 2024

Do you mind to rebase your PR against v2 branch? πŸ™πŸΌ

@pi0 pi0 changed the title feat: better error message when worker fails feat(dev): attach worker reload error case Aug 12, 2024
@tobiasdiez tobiasdiez changed the base branch from main to v2 August 12, 2024 12:41
@pi0 pi0 changed the title feat(dev): attach worker reload error case refactor(dev): attach worker reload error as cause Sep 20, 2024
Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

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

Thanks! This is better apporach for error capturing since cause is widely supported.

I've added a final change to keep unrelated nitro internals hidden from trace using Error.captureStackTrace

@pi0 pi0 merged commit 1fa2b5e into unjs:v2 Sep 20, 2024
4 checks passed
@tobiasdiez tobiasdiez deleted the patch-1 branch September 20, 2024 15:40
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.

2 participants