yarnpkg / berry

📦🐈 Active development trunk for Yarn ⚒
https://yarnpkg.com
BSD 2-Clause "Simplified" License
7.37k stars 1.1k forks source link

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

Closed aladdin-add closed 2 years ago

aladdin-add commented 2 years ago

Self-service

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

patdx commented 2 years ago

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)

Dragon1573 commented 2 years ago

@patdx & @aladdin-add , I'm currently facing the same problem.

Should I downgrade my Node.js to LTS v16.x version? Thank you! ❤️

🔧 Self-Service

📜 Describe the bug

Error logs are as follows:

(base) Study-Notes on main ● λ yarn add -D vuepress-theme-vdoing
➤ YN0000: ┌ Resolution step
➤ YN0002: │ @vue/babel-plugin-jsx@npm:1.0.7 doesn't provide @babel/core (pa6c52), requested by @babel/plugin-syntax-jsx
➤ YN0002: │ @vuepress/core@npm:1.8.2 doesn't provide @vue/compiler-sfc (p4c8a9), requested by vue-loader
➤ YN0002: │ study-notes@workspace:. doesn't provide chalk (p75ef5), requested by vuepress-plugin-sitemap
➤ YN0002: │ study-notes@workspace:. doesn't provide commander (p17913), requested by vuepress-plugin-sitemap
➤ YN0002: │ study-notes@workspace:. doesn't provide esm (p844b2), requested by vuepress-plugin-sitemap
➤ YN0000: │ Some peer dependencies are incorrectly met; run yarn explain peer-requirements <hash> for details, where <hash> is the six-letter p-prefixed code
➤ YN0000: └ Completed in 0s 873ms
➤ YN0000: ┌ Fetch step
➤ YN0013: │ @better-scroll/core@npm:2.4.2 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ @better-scroll/shared-utils@npm:2.4.2 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ @better-scroll/slide@npm:2.4.2 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ good-storage@npm:1.1.1 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ vuepress-theme-vdoing@npm:1.8.5 can't be found in the cache and will be fetched from the remote registry
➤ 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)
➤ YN0000: └ Completed in 0s 726ms
➤ YN0000: Failed with errors in 1s 603ms

🎯 To reproduce

yarn add -D vuepress-theme-vdoing

🖥️ Environment

❓ Aditional Context

  1. I'm currently using a mirror service hosted by Huawei.
  2. The required version of package is uploaded to that mirror.
  3. I'm located in Mainland China, but the IP address of my device is in Chinese Taipei, I can't sure if I'm behind a proxy service (no need to configure locally).
Dragon1573 commented 2 years ago

I invoked yarn add -D vuepress-theme-vdoing several times, it first failed with Y0001 error but suddenly "fixed" itself and installed the dependency successfully (only with some unimportant warnings). Can't reproduce it again.

(base) Study-Notes on main ● λ yarn add -D vuepress-theme-vdoing
➤ YN0000: ┌ Resolution step
➤ YN0002: │ @vue/babel-plugin-jsx@npm:1.0.7 doesn't provide @babel/core (pa6c52), requested by @babel/plugin-syntax-jsx
➤ YN0002: │ @vuepress/core@npm:1.8.2 doesn't provide @vue/compiler-sfc (p4c8a9), requested by vue-loader
➤ YN0002: │ study-notes@workspace:. doesn't provide chalk (p75ef5), requested by vuepress-plugin-sitemap
➤ YN0002: │ study-notes@workspace:. doesn't provide commander (p17913), requested by vuepress-plugin-sitemap
➤ YN0002: │ study-notes@workspace:. doesn't provide esm (p844b2), requested by vuepress-plugin-sitemap
➤ YN0000: │ Some peer dependencies are incorrectly met; run yarn explain peer-requirements <hash> for details, where <hash> is the six-letter p-prefixed code
➤ YN0000: └ Completed
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed in 0s 497ms
➤ YN0000: ┌ Link step
➤ YN0076: │ fsevents@patch:fsevents@npm%3A1.2.13#~builtin<compat/fsevents>::version=1.2.13&hash=18f3a7 The win32-x64 architecture is incompatible with this module, link skipped.
➤ YN0076: │ fsevents@patch:fsevents@npm%3A2.3.2#~builtin<compat/fsevents>::version=2.3.2&hash=18f3a7 The win32-x64 architecture is incompatible with this module, link skipped.
➤ YN0000: └ Completed in 0s 777ms
➤ YN0000: Done with warnings in 1s 562ms
aladdin-add commented 2 years ago
  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).
Dragon1573 commented 2 years ago

@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.
leotm commented 2 years ago

@aladdin-add M V P ❤️

on a side-note, also my hero back in ole '96 homebrewprefix issue


yarn set version from sources

also works (v3.2.0-rc.3)

and gets me past TypeError: e is not iterable in yarn-berry.cjs locally

and fixes CI failing to upgrade to v3.1.0

bmaier commented 2 years ago

Following command solved the issue in my environment:

yarn set version latest

banagale commented 2 years ago

I had this issue trying to yard add stripe. Error was YN0001: │ Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close.

@bmaier 's yarn set version latest took my yarn to 3.1.1 which allowed me to successfully run yarn add stripe.

hargup commented 2 years ago

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?

antoooooooooooonie commented 2 years ago

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 😅 .

merceyz commented 2 years ago

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

antoooooooooooonie commented 2 years ago

Is there any sort of comprehensive document on how to upgrade from yarn@2.x.x to yarn@3.x.x?

sk22 commented 1 year ago

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!

jeffrafter commented 1 year ago

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.

sideshowbarker commented 7 months ago

Setting YARN_CHECKSUM_BEHAVIOR=update in the environment is the only thing that worked for me.

That is, either doing export YARN_CHECKSUM_BEHAVIOR=update or else running YARN_CHECKSUM_BEHAVIOR=update yarn as the command, instead of just yarn.

(from https://stackoverflow.com/a/71276936/441757, via https://github.com/substrate-developer-hub/substrate-front-end-template/issues/213#issuecomment-1051812768)

Kitanit commented 3 months ago

docker 6.1.0 same error, S3 BackBlaze

image