berry: [Bug?]: node 16.17.0 update cause yarn 3.2.2 build to fail

Self-service

  • I’d be willing to implement a fix

Describe the bug

I apologize, I cannot provide too much information about our project, I hope other people who get here will be able to add to this. I’m reporting this, since you requested it in other issue, but sorry if this is not enough info.

Our yarn build of typescript react app is part of ubuntu image build and we are using Jenkins and CMake. We are installing node from https://deb.nodesource.com/setup_16.x which yesterday got updated from 16.16.x to 16.17.0. Our project was using 3.2.1. After we found someone reported same issue on node 18, we found a suggestion to try

yarn set version stable && yarn install

However build is still failing on yarn 3.2.2 using node 16.17.0 with the following error logs:

[2022-08-17T04:53:35.170Z] ERRO[0690] node:internal/errors:477                     
[2022-08-17T04:53:35.170Z] ERRO[0690]     ErrorCaptureStackTrace(err);             
[2022-08-17T04:53:35.170Z] ERRO[0690]     ^                                        
[2022-08-17T04:53:35.170Z] ERRO[0690]                                              
[2022-08-17T04:53:35.170Z] ERRO[0690] Error [ERR_LOADER_CHAIN_INCOMPLETE]: "file:///blablabla/src_files/.pnp.loader.mjs 'resolve'" did not call the next hook in its chain and did not explicitly signal a short circuit. If this is intentional, include `shortCircuit: true` in the hook's return. 
[2022-08-17T04:53:35.170Z] ERRO[0690]     at new NodeError (node:internal/errors:387:5) 
[2022-08-17T04:53:35.170Z] ERRO[0690]     at ESMLoader.resolve (node:internal/modules/esm/loader:852:13) 
[2022-08-17T04:53:35.170Z] ERRO[0690]     at async ESMLoader.getModuleJob (node:internal/modules/esm/loader:431:7) 
[2022-08-17T04:53:35.170Z] ERRO[0690]     at async Promise.all (index 0)           
[2022-08-17T04:53:35.170Z] ERRO[0690]     at async ESMLoader.import (node:internal/modules/esm/loader:533:24) 
[2022-08-17T04:53:35.170Z] ERRO[0690]     at async loadESM (node:internal/process/esm_loader:91:5) 
[2022-08-17T04:53:35.170Z] ERRO[0690]     at async handleMainPromise (node:internal/modules/run_main:65:12) { 
[2022-08-17T04:53:35.170Z] ERRO[0690]   code: 'ERR_LOADER_CHAIN_INCOMPLETE'        
[2022-08-17T04:53:35.170Z] ERRO[0690] }                       

Our only solution for now is to downgrade node to use 16.16.x during the build. Would be nice to have this resolved so we could go back to using latest stable node.

In other thread you have mentioned that it should be fixed. I wonder if there’s something else need to be done, since we upgraded from 3.2.1 instead of having project on 3.2.2 from the start?

To reproduce

I’m sorry that I cannot provide more info about our project, other than this brief description:

  1. setup typescript react app using yarn 3.2.1
  2. use official stable node https://deb.nodesource.com/setup_16.x
  3. Fail to build
  4. yarn set version stable && yarn install
  5. retry and still fail to build

Environment

I cannot run script to get env info, since it's a automated build environment and I'm not part of the team who set it up.
Node: 16.17.0
Yarn: 3.2.2

Additional context

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 13
  • Comments: 18 (4 by maintainers)

Commits related to this issue

Most upvoted comments

This got fixed in 3.2.2. Are you sure you are using this version? Did you run yarn install after the upgrade?

I’m running into this problem with one of my repos. It appears that the problem might be related to experimental changes to the ESM Loader Hooks API in Node 16.17.0 in this PR. Pinning my Node version to 16.16.0 solves the problem for now. I don’t have the time to dig deeper, but at first glance, it appears this is a breaking change to Node, since it breaks existing loaders that have not yet updated to signal a short circuit when not calling the next loader.

It’s a node version issue. I’m using now nvm with a node@16.15.1 an it works well now

Turns out we don’t even commit .pnp.loader.mjs so the problem is not with that. I was able to build it locally successfully with node 16.17.0 + yarn 3.2.2 combo, but in our automated build (which doesn’t have anything cached btw, it downloads and builds everything from scratch) it still failing with the same error. At this point I’m going to blame our build setup, we’ll have to figure it out internally.

I think Yarn 3.2.2 is fine and this issue can be closed. If/when we figure out our issue, I’ll post it here for anyone who will encounter same problem.

thanks @Wedvich maybe deleting .pnp.loader.mjs is the step we were missing. I’ll try to test it tomorrow.

The problem retroactively affected weeks-old commits that, at the time of their commits, tested and functioned perfectly fine.

If you want those sorts of guarantees you must keep your entire stack under control. I recommend using Nix for that.

I got the same error on Node >= 16.17 even on Yarn 3.2.2:

  System:
    OS: Linux 5.10 Ubuntu 20.04.4 LTS (Focal Fossa)
    CPU: (16) x64 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz
  Binaries:
    Node: 16.17.0 - /tmp/xfs-b98f7329/node
    Yarn: 3.2.2 - /tmp/xfs-b98f7329/yarn
    npm: 8.15.0 - ~/.nvm/versions/node/v16.17.0/bin/npm

However, I started out with Yarn 3.2.0 and that’s the version that generated the .pnp.loader.mjs file that’s checked in to source control. Just running yarn after setting the version to 3.2.2 did nothing, but after deleting that file and running yarn again, it got regenerated with the updates and now it works 🎉

This got fixed in 3.2.2. Are you sure you are using this version? Did you run yarn install after the upgrade?

@arcanis I get the same error as @shestakov-bc (yarn 3.2.2). Works on 16.16.0, fails on 16.17.0