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

webpack/runtime/compat The "path" argument must be of type string. Received undefined with new Worker(new URL(...)) and worker import(s) #2220

Open
talaikis opened this issue Dec 21, 2021 · 2 comments

Comments

@talaikis
Copy link

Issue Summary

webpack/runtime/compat The "path" argument must be of type string. Received undefined with new Worker(new URL(...)) and comlink

Actual behavior

webpack/runtime/compat The "path" argument must be of type string

Expected behavior

Probably should work, because nextjs build worksfine.

Steps to reproduce

Repo: https://github.com/talaikis/next-worker-comlink-repro

on deployment gives Error:

warn  - No ESLint configuration detected. Run next lint to begin setup
Failed to compile.

webpack/runtime/compat
The "path" argument must be of type string. Received undefined


> Build failed because of webpack errors
info  - Checking validity of types...
info  - Creating an optimized production build...
    at makeError (C:\Users\DXenu\.serverless\components\registry\npm\@sls-next\serverless-component@3.6.0\node_modules\@sls-next\serverless-component\node_modules\execa\lib\error.js:60:11)
    at handlePromise (C:\Users\DXenu\.serverless\components\registry\npm\@sls-next\serverless-component@3.6.0\node_modules\@sls-next\serverless-component\node_modules\execa\index.js:118:26)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async Builder.build (C:\Users\DXenu\.serverless\components\registry\npm\@sls-next\serverless-component@3.6.0\node_modules\@sls-next\serverless-component\node_modules\@sls-next\lambda-at-edge\dist\build.js:377:13)
    at async NextjsComponent.build (C:\Users\DXenu\.serverless\components\registry\npm\@sls-next\serverless-component@3.6.0\node_modules\@sls-next\serverless-component\dist\component.js:165:13)
    at async NextjsComponent.default (C:\Users\DXenu\.serverless\components\registry\npm\@sls-next\serverless-component@3.6.0\node_modules\@sls-next\serverless-component\dist\component.js:22:13)
    at async fn (\with-next-worker-repro\node_modules\@serverless\template\utils.js:280:41)
    at async Promise.all (index 0)
    at async executeGraph (\with-next-worker-repro\node_modules\@serverless\template\utils.js:294:3)
    at async Template.default (\with-next-worker-repro\node_modules\@serverless\template\serverless.js:67:38) {
  shortMessage: 'Command failed with exit code 1: node_modules/.bin/next build',
  command: 'node_modules/.bin/next build',
  escapedCommand: '"node_modules/.bin/next" build',
  exitCode: 1,
  signal: undefined,
  signalDescription: undefined,
  stdout: 'info  - Checking validity of types...\n' +
    'info  - Creating an optimized production build...',
  stderr: 'warn  - The `target` config is deprecated and will be removed in a future version.\n' +
    'See more info here https://nextjs.org/docs/messages/deprecated-target-config\n' +
    'warn  - No ESLint configuration detected. Run next lint to begin setup\n' +
    'Failed to compile.\n' +
    '\n' +
    'webpack/runtime/compat\n' +
    'The "path" argument must be of type string. Received undefined\n' +
    '\n' +
    '\n' +
    '> Build failed because of webpack errors',
  failed: true,
  timedOut: false,
  isCanceled: false,
  killed: false
}

Versions

  • OS/Environment: Windows 11
  • @sls-next/serverless-component version: 3.6.0
  • Next.js version: 12.0.7

Checklist

  • [ x] You have reviewed the README and FAQs, which answers several common questions.
  • [x ] You have reviewed our DEBUGGING wiki and have tried your best to include complete information and reproduction steps (including your configuration) as is possible. As there is only one maintainer (who maintains this in his free time) and thus very limited resources, if you have time, please try to debug the issue a bit yourself if possible.
  • [x ] You have first tried using the most recent latest or alpha @sls-next/serverless-component release version, which may have already fixed your issue or implemented the feature you are trying to use. Note that the old serverless-next.js component and the serverless-next.js plugin are deprecated and no longer maintained.
@talaikis talaikis changed the title webpack/runtime/compat The "path" argument must be of type string. Received undefined with new Worker(new URL(...)) and comlink webpack/runtime/compat The "path" argument must be of type string. Received undefined with new Worker(new URL(...)) and worker import(s) Dec 29, 2021
@manmal
Copy link

manmal commented Jan 12, 2022

I got this error when importing (or requiring) a relative path in a file that the web worker imports.

The following workaround worked for me:

const properties = require(path.join(process.cwd(), `data/file.json`));

instead of

const properties = require(`../data/file.json`));

@talaikis
Copy link
Author

Well, without any relative imports, it does not work with imported packages.

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

No branches or pull requests

2 participants