berry: [Bug?]: node17 compat: │ Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close

Self-service

  • I’d be willing to implement a fix

Describe the bug

Fetch step ➤ YN0001: │ Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close at new NodeError (node:internal/errors:371:5) at PassThrough.onclose (node:internal/streams/end-of-stream:122:30) at PassThrough.emit (node:events:390:28) at emitCloseNT (node:internal/streams/destroy:145:10) at processTicksAndRejections (node:internal/process/task_queues:82:21)

To reproduce

https://github.com/weiran-zsd/dts-cli/runs/3947685268

Environment

os: ubuntu-latest
Node.js: v17.0.0
yarn: v3.0.2

Additional context

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 24
  • Comments: 15 (1 by maintainers)

Commits related to this issue

Most upvoted comments

  1. it has been fixed in latest yarn, so please upgrade: yarn set version latest.
  2. As v17 is not a lts, please use node v16/v14 in production (node:latest => node:lts).

Following command solved the issue in my environment:

yarn set version latest

@aladdin-add , Thank you! ❤️

  1. I have invoked yarn set version berry and upgraded to v3.1.0, it DOES solved the problem! 🎉
  2. I’m new to Node.js and Yarn, just because I want to publish my notes to GitHub Pages using VuePress. There’re too many things that I didn’t know before. I’ll downgrade to the latest LTS version of Node.js as you instructed.

since this issue describes the problem i had pretty well, but i didn’t find my solution here, i think i’ll share what made it work in my case (trying to get govuk-react running on my computer):

after running yarn set version latest (which upgraded the local yarn installation to 3.2.4), i also had the Cannot redefine settings "changesetBaseRefs" error when running yarn.

so, i ended up deleting the .yarn/plugins/@yarnpkg folder and deleting entries from the plugins section in .yarnrc.yml, which looked like this before

  plugins:
-   - path: .yarn/plugins/@yarnpkg/plugin-version.cjs
-     spec: "@yarnpkg/plugin-version"
-   - path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
-     spec: "@yarnpkg/plugin-workspace-tools"
-   - path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs
-     spec: "@yarnpkg/plugin-typescript"

i then ran these commands to reinstall the plugins:

yarn plugin import @yarnpkg/plugin-version
yarn plugin import @yarnpkg/plugin-workspace-tools
yarn plugin import @yarnpkg/plugin-typescript

since i’m not used to yarn, i don’t know how usually to go about this issue, but the described worked for me. no more errors when running yarn!

For folks showing up here from Google… in modern times yarn set version stable might be better for you. This will force major upgrades (which could be good or bad) but will often get you around other issues.

Updating yarn to latest leads me to a new error:

Internal Error: Cannot redefine settings "changesetBaseRefs"
    at Xa.importSettings (/Users/harshgupta/code/instant-apps/.yarn/releases/yarn-3.2.0.cjs:395:24057)
    at Xa.activatePlugin (/Users/harshgupta/code/instant-apps/.yarn/releases/yarn-3.2.0.cjs:395:23932)
    at Function.find (/Users/harshgupta/code/instant-apps/.yarn/releases/yarn-3.2.0.cjs:395:22198)
    at async i (/Users/harshgupta/code/instant-apps/.yarn/releases/yarn-3.2.0.cjs:448:11309)
    at async r (/Users/harshgupta/code/instant-apps/.yarn/releases/yarn-3.2.0.cjs:448:10887)

Any clue on how I can go about fixing it?

You need to update the plugins you’re using as well

Updating yarn to latest leads me to a new error:

Internal Error: Cannot redefine settings "changesetBaseRefs"
    at Xa.importSettings (/Users/harshgupta/code/instant-apps/.yarn/releases/yarn-3.2.0.cjs:395:24057)
    at Xa.activatePlugin (/Users/harshgupta/code/instant-apps/.yarn/releases/yarn-3.2.0.cjs:395:23932)
    at Function.find (/Users/harshgupta/code/instant-apps/.yarn/releases/yarn-3.2.0.cjs:395:22198)
    at async i (/Users/harshgupta/code/instant-apps/.yarn/releases/yarn-3.2.0.cjs:448:11309)
    at async r (/Users/harshgupta/code/instant-apps/.yarn/releases/yarn-3.2.0.cjs:448:10887)

Any clue on how I can go about fixing it?

I’m getting the same issue. Feels like I’m going in circles 😅 .

Thanks for posting this issue, helped me figure out why I suddenly started seeing ERR_STREAM_PREMATURE_CLOSE errors in CI. It turned out I had an issue with my Dockerfile as I had written:

FROM node:alpine AS builder

Which I guess suddenly starting pulling the Node v17 image today. I should have written:

FROM node:lts-alpine AS builder

(or something like this)