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]: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined #8362

Closed
whimboo opened this issue May 18, 2022 · 3 comments
Labels

Comments

@whimboo
Copy link
Collaborator

whimboo commented May 18, 2022

Bug description

This is a problem that I can currently see locally when trying to run the Puppeteer unit tests with the latest upstream revision. Once it failed it always fails even for installing Puppeteer. The only workaround is to manually remove the lib/ folder with generated code.

Steps to reproduce the problem:

  1. Pull latest changes from upstream repository
  2. Checkout revision 82f84c9
  3. Run npm install => success
  4. Run npm run funit => success
  5. Checkout e.g revision 7107d2d
  6. Run npm install => success
  7. Run npm run funit => failure
  8. Run npm install => failure

@OrKoN maybe these steps help to analyze the problem. At least for me these always reproduce it.

Puppeteer version

14.1.0-post

Node.js version

v17.9.0

npm version

v8.5.5

What operating system are you seeing the problem on?

macOS

Relevant log output

> puppeteer@14.1.0-post funit
> cross-env PUPPETEER_PRODUCT=firefox npm run unit


> puppeteer@14.1.0-post unit
> npm run tsc-cjs && mocha --config mocha-config/puppeteer-unit-tests.js


> puppeteer@14.1.0-post tsc-cjs
> tsc -b src/tsconfig.cjs.json


✖ ERROR: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at new NodeError (node:internal/errors:372:5)
    at validateString (node:internal/validators:120:11)
    at dirname (node:path:1276:5)
    at Object.<anonymous> (/Users/henrik/code/puppeteer/src/constants.ts:4:51)
    at Module._compile (node:internal/modules/cjs/loader:1099:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Object.require.extensions.<computed> [as .js] (/Users/henrik/code/puppeteer/node_modules/ts-node/src/index.ts:1445:43)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:999:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/henrik/code/puppeteer/src/initialize-node.ts:21:1)
    at Module._compile (node:internal/modules/cjs/loader:1099:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Object.require.extensions.<computed> [as .js] (/Users/henrik/code/puppeteer/node_modules/ts-node/src/index.ts:1445:43)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:999:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/henrik/code/puppeteer/src/node.ts:17:1)
    at Module._compile (node:internal/modules/cjs/loader:1099:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Object.require.extensions.<computed> [as .js] (/Users/henrik/code/puppeteer/node_modules/ts-node/src/index.ts:1445:43)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:999:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/henrik/code/puppeteer/test/mocha-utils.ts:22:1)
    at Module._compile (node:internal/modules/cjs/loader:1099:14)
    at Module.m._compile (/Users/henrik/code/puppeteer/node_modules/ts-node/src/index.ts:1455:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Object.require.extensions.<computed> [as .ts] (/Users/henrik/code/puppeteer/node_modules/ts-node/src/index.ts:1458:12)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:999:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at exports.requireOrImport (/Users/henrik/code/puppeteer/node_modules/mocha/lib/nodejs/esm-utils.js:49:16)
    at async exports.handleRequires (/Users/henrik/code/puppeteer/node_modules/mocha/lib/cli/run-helpers.js:94:28)
    at async /Users/henrik/code/puppeteer/node_modules/mocha/lib/cli/run.js:349:25 {
  code: 'ERR_INVALID_ARG_TYPE'
}
➜  puppeteer git:(main) ✗ npm install                                                                                                                        
> puppeteer@14.1.0-post install
> node install.js

node:internal/errors:465
    ErrorCaptureStackTrace(err);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at new NodeError (node:internal/errors:372:5)
    at validateString (node:internal/validators:120:11)
    at dirname (node:path:1276:5)
    at Object.<anonymous> (/Users/henrik/code/puppeteer/lib/cjs/puppeteer/constants.js:6:82)
    at Module._compile (node:internal/modules/cjs/loader:1099:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:999:19)
    at require (node:internal/modules/cjs/helpers:102:18) {
  code: 'ERR_INVALID_ARG_TYPE'
}
@whimboo whimboo added the bug label May 18, 2022
@whimboo
Copy link
Collaborator Author

whimboo commented May 18, 2022

Line 6 of constants.js actually contains the following:

exports.rootDirname = (0, path_1.dirname)((0, path_1.dirname)((0, path_1.dirname)(compat_js_1.puppeteerDirname)));

@whimboo
Copy link
Collaborator Author

whimboo commented May 18, 2022

compat.js exports the puppeteerDirname as: exports.puppeteerDirname = void 0;. So yes, this is broken.

OrKoN added a commit that referenced this issue May 18, 2022
Running only tsc-cjs does not seem sufficient for rebuilding
the project after the compat layer for ESM was introduced.
Let's run `tsc` instead although it's somewhat slower.

Issues: #8362
OrKoN added a commit that referenced this issue May 18, 2022
Running only tsc-cjs does not seem sufficient for rebuilding
the project after the compat layer for ESM was introduced.
Let's run `tsc` instead although it's somewhat slower.

Issues: #8362
OrKoN added a commit that referenced this issue May 18, 2022
Running only tsc-cjs does not seem sufficient for rebuilding
the project after the compat layer for ESM was introduced.
Let's run `tsc` instead although it's somewhat slower.

Issues: #8362
OrKoN added a commit that referenced this issue May 19, 2022
Running only tsc-cjs does not seem sufficient for rebuilding
the project after the compat layer for ESM was introduced.
Let's run `tsc` instead although it's somewhat slower.

Issues: #8362
OrKoN added a commit that referenced this issue May 19, 2022
Running only tsc-cjs does not seem sufficient for rebuilding
the project after the compat layer for ESM was introduced.
Let's run `tsc` instead although it's somewhat slower.

Issues: #8362
OrKoN added a commit that referenced this issue May 19, 2022
Running only tsc-cjs does not seem sufficient for rebuilding
the project after the compat layer for ESM was introduced.
Let's run `tsc` instead although it's somewhat slower.

Issues: #8362
@OrKoN
Copy link
Collaborator

OrKoN commented May 19, 2022

Thanks for the detailed report! I think this should be fixed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment