Skip to content

Running any script with pnp on node 13.0.1: "TypeError: paths is not iterable" #7642

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

Closed
sverweij opened this issue Oct 23, 2019 · 6 comments · Fixed by #7650
Closed

Running any script with pnp on node 13.0.1: "TypeError: paths is not iterable" #7642

sverweij opened this issue Oct 23, 2019 · 6 comments · Fixed by #7650

Comments

@sverweij
Copy link
Contributor

sverweij commented Oct 23, 2019

Do you want to request a feature or report a bug?
A bug (or I'm doing something stupid...)

What is the current behavior?

  • On node 13 running a lifecycle script with yarn (with pnp enabled) errors with TypeError: paths is not iterable (see below).
  • With the same files, on node 12 the script runs ok.
/home/runner/work/yarn-on-node-13/yarn-on-node-13/.pnp.js:747
    for (const path of paths) {
                       ^

TypeError: paths is not iterable
    at Function.Module._findPath (/home/runner/work/yarn-on-node-13/yarn-on-node-13/.pnp.js:747:24)
    at resolveMainPath (internal/bootstrap/pre_execution.js:447:28)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1046:24)
    at internal/main/run_main_module.js:16:11

If the current behavior is a bug, please provide the steps to reproduce.

On node 13, with yarn plug'n play enabled, run any javascript through yarn.

I've created a minimum reproduction repo on sverweij/yarn-on-node-13
In there: run yarn cache clean && yarn && yarn test
(You can see what happens in the GitHub actions tab of the repo...

What is the expected behavior?

The lifecycle script runs without errors (just like on node 12).

Please mention your node.js, yarn and operating system version.

node.js: 13.0.1
yarn: 1.19.1 (and 2.0.0-rc.6)
OS: macOS 10.14.6

@sverweij sverweij changed the title Running a script with pnp on node 13.0.1: "TypeError: paths is not iterable" Running any script with pnp on node 13.0.1: "TypeError: paths is not iterable" Oct 25, 2019
@arcanis
Copy link
Member

arcanis commented Oct 26, 2019

Can you check whether the same is true for Yarn v2?

@sverweij
Copy link
Contributor Author

sverweij commented Oct 26, 2019

it is - check out this run with the same repo using yarn 2.0.0-rc.6: https://github.com/sverweij/yarn-on-node-13/runs/272305615

@sverweij
Copy link
Contributor Author

Some research:

  • on node 12 (and below) with the MRS above the Module._findPath as patched in .pnp.js is never called
  • on node 13 it is, and it gets these arguments passed:
{
  '0': '/Users/sander/path/to/index.js',
  '1': null,
  '2': true
}
  • the diff between node 13.x branch and master shows the likely culprit is a new call to _findPath in lib/internal/bootstrap/pre_execution.js, with the values path.resolve(main), null and true -

I patched the line in the local .pnp.js to take that into account, like so:

for (const path of paths || []) {

... and with that the problem seems to be gone.

I could make a PR to change generate-pnp-map-api.tpl.js likewise (and the same in berry, I guess?)

@arcanis
Copy link
Member

arcanis commented Oct 26, 2019

That would be great! I can't make the fix atm but I can merge it, and you can start using it through yarn set version from sources (v2).

@SimenB
Copy link
Contributor

SimenB commented Oct 26, 2019

might be worth considering getting yarn into citgm so these breakages are caught before making it into a node stable release?

@arcanis
Copy link
Member

arcanis commented Oct 28, 2019

might be worth considering getting yarn into citgm so these breakages are caught before making it into a node stable release?

Yep! I think the v1 is already there but the PnP path isn't covered at the moment. Maybe we could add the v2 and test both versions, since they have significantly different implementations.

On our side we also have our own kind of "Canary in the goldmine" program, but I'm not sure whether Node publishes nightly builds that we could use for this purpose 🤔

[edit] Seems like there is! We should definitely add a test on our side too, then.

arcanis pushed a commit that referenced this issue Nov 7, 2019
* ci(circleci): prevent timeout on circle-ci macos node10 build

The circle ci job for macOS on node 10 currently fails because it takes too long
(both PR's #7649 and #7650 don't green because of that). A big chunk of the time
is taken by updating homebrew - which in this macOS (the one connected to xcode 9
=> macOS 10.12) does not contain node 10 by default.

This change:
- sets the required xcode version to 11.0 -> this gets us a more up to date macOS
  version (except for node 6, which isn't available in the homebrew associated
  with xcode 11)
- removes the brew update from the macOS node 10 job

* fix(generate-pnp-map-api.tpl.js): make running with Plug'n Play possible on node 13

On node 13 Module._findPath (which the setup() of this module redefines) also gets
called with null for the path parameter (by lib/internal/bootstrap/pre_execution.js
in the (new) function resolveMainPath).

This fix ensures the patched _findPath also handles that situation.

* ci(azure-pipelines): add node 13 (and 12) to the azure-pipeline matrix

#7642

* ci(circleci): add node 13 (and 12) to the build matrix (linux)

* docs(CHANGELOG.md): adds PR #7650 to the change log
arcanis pushed a commit that referenced this issue Nov 22, 2019
* ci(circleci): prevent timeout on circle-ci macos node10 build

The circle ci job for macOS on node 10 currently fails because it takes too long
(both PR's #7649 and #7650 don't green because of that). A big chunk of the time
is taken by updating homebrew - which in this macOS (the one connected to xcode 9
=> macOS 10.12) does not contain node 10 by default.

This change:
- sets the required xcode version to 11.0 -> this gets us a more up to date macOS
  version (except for node 6, which isn't available in the homebrew associated
  with xcode 11)
- removes the brew update from the macOS node 10 job

* fix(generate-pnp-map-api.tpl.js): make running with Plug'n Play possible on node 13

On node 13 Module._findPath (which the setup() of this module redefines) also gets
called with null for the path parameter (by lib/internal/bootstrap/pre_execution.js
in the (new) function resolveMainPath).

This fix ensures the patched _findPath also handles that situation.

* ci(azure-pipelines): add node 13 (and 12) to the azure-pipeline matrix

#7642

* ci(circleci): add node 13 (and 12) to the build matrix (linux)

* docs(CHANGELOG.md): adds PR #7650 to the change log
VincentBailly pushed a commit to VincentBailly/yarn that referenced this issue Jun 10, 2020
* ci(circleci): prevent timeout on circle-ci macos node10 build

The circle ci job for macOS on node 10 currently fails because it takes too long
(both PR's yarnpkg#7649 and yarnpkg#7650 don't green because of that). A big chunk of the time
is taken by updating homebrew - which in this macOS (the one connected to xcode 9
=> macOS 10.12) does not contain node 10 by default.

This change:
- sets the required xcode version to 11.0 -> this gets us a more up to date macOS
  version (except for node 6, which isn't available in the homebrew associated
  with xcode 11)
- removes the brew update from the macOS node 10 job

* fix(generate-pnp-map-api.tpl.js): make running with Plug'n Play possible on node 13

On node 13 Module._findPath (which the setup() of this module redefines) also gets
called with null for the path parameter (by lib/internal/bootstrap/pre_execution.js
in the (new) function resolveMainPath).

This fix ensures the patched _findPath also handles that situation.

* ci(azure-pipelines): add node 13 (and 12) to the azure-pipeline matrix

yarnpkg#7642

* ci(circleci): add node 13 (and 12) to the build matrix (linux)

* docs(CHANGELOG.md): adds PR yarnpkg#7650 to the change log
VincentBailly pushed a commit to VincentBailly/yarn that referenced this issue Jun 10, 2020
* ci(circleci): prevent timeout on circle-ci macos node10 build

The circle ci job for macOS on node 10 currently fails because it takes too long
(both PR's yarnpkg#7649 and yarnpkg#7650 don't green because of that). A big chunk of the time
is taken by updating homebrew - which in this macOS (the one connected to xcode 9
=> macOS 10.12) does not contain node 10 by default.

This change:
- sets the required xcode version to 11.0 -> this gets us a more up to date macOS
  version (except for node 6, which isn't available in the homebrew associated
  with xcode 11)
- removes the brew update from the macOS node 10 job

* fix(generate-pnp-map-api.tpl.js): make running with Plug'n Play possible on node 13

On node 13 Module._findPath (which the setup() of this module redefines) also gets
called with null for the path parameter (by lib/internal/bootstrap/pre_execution.js
in the (new) function resolveMainPath).

This fix ensures the patched _findPath also handles that situation.

* ci(azure-pipelines): add node 13 (and 12) to the azure-pipeline matrix

yarnpkg#7642

* ci(circleci): add node 13 (and 12) to the build matrix (linux)

* docs(CHANGELOG.md): adds PR yarnpkg#7650 to the change log
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