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?]: node17 compat: │ Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close #3597

Closed
1 task
aladdin-add opened this issue Oct 20, 2021 · 15 comments · Fixed by #3610
Closed
1 task

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

aladdin-add opened this issue Oct 20, 2021 · 15 comments · Fixed by #3610
Labels
bug Something isn't working upholded Real issues without formal reproduction

Comments

@aladdin-add
Copy link

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

@aladdin-add aladdin-add added the bug Something isn't working label Oct 20, 2021
@paul-soporan paul-soporan added the upholded Real issues without formal reproduction label Oct 21, 2021
@patdx
Copy link

patdx commented Oct 28, 2021

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
Copy link

@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

  • I'd be willing to implement a fix

📜 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

  • Operating System
    • Name: Microsoft Windows 10 Professional (zh-CN)
    • Version: 10.0.19043 N/A Build 19043
    • Build Type: Multiprocessor Free
    • System Type: x64-based PC
  • Nodejs Version: v17.0.1
  • NPM Version: v8.1.0
  • Yarn Version: v3.1.0

❓ 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
Copy link

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
Copy link
Author

aladdin-add commented Nov 1, 2021

  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
Copy link

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

PiDelport added a commit to registreerocks/registree-core that referenced this issue Nov 10, 2021
This avoids the following Yarn / Node 17 regression:

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

<yarnpkg/berry#3597>

(This has already been fixed in newer Yarn, but we want to stick to the
LTS anyway.)
PiDelport added a commit to registreerocks/registree-core that referenced this issue Nov 10, 2021
* ci(circleci): fix Node versions to 16 (LTS), rather than 17

This avoids the following Yarn / Node 17 regression:

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

<yarnpkg/berry#3597>

(This has already been fixed in newer Yarn, but we want to stick to the
LTS anyway.)

* ci(circleci): update circleci/node orb, and use new yarn-berry support

Also drop link to
<CircleCI-Public/node-orb#63>: the issue has
been resolved, but there still isn't a partial restore key without the
branch name when include-branch-in-cache-key is enabled.
@leotm
Copy link

leotm commented Nov 13, 2021

@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

leotm added a commit to leotm/react-native-template-new-architecture that referenced this issue Nov 13, 2021
Resolve both issues from OP and comment

yarnpkg/berry#3597 (comment)

yarn-berry.cjs name looks deprecated, favouring explicit semver

Prefer this too, since current ver 3.0.2 was hard to dig-up from yarn-berry.cjs
leotm added a commit to leotm/react-native-template-new-architecture that referenced this issue Nov 13, 2021
Follow-up on yarnpkg/berry#3597 (comment) / 6b81235

No yarn.lock change noted this on from follow-up yarn install

yarn set version berry - added to package.json:
"packageManager": "yarn@3.1.0"
CLI forgetting to cleanup, manually revert, appears to have no effect
Raise issue if not already, consider PR contrib

Note .yarn/releases/yarn-<name>.cjs switching between named <-> explicit 🔄
- berry -> 3.1.0 -> sources
@bmaier
Copy link

bmaier commented Dec 18, 2021

Following command solved the issue in my environment:

yarn set version latest

@banagale
Copy link

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
Copy link

hargup commented Feb 26, 2022

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
Copy link

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
Copy link
Member

merceyz commented Mar 8, 2022

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

@antoooooooooooonie
Copy link

antoooooooooooonie commented Mar 8, 2022

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

tony added a commit to tony/cv that referenced this issue Sep 5, 2022
See also: https://yarnpkg.com/getting-started/migration

Squashed:

yarn set version berry (3.0 -> 3.1+) to fix ERR_STREAM_PREMATURE_CLOSE

In our case this bumped to 3.2.3

See also: yarnpkg/berry#3597
tony added a commit to tony/cv that referenced this issue Sep 5, 2022
See also: https://yarnpkg.com/getting-started/migration

Squashed:

yarn set version berry (3.0 -> 3.1+) to fix ERR_STREAM_PREMATURE_CLOSE

In our case this bumped to 3.2.3

See also: yarnpkg/berry#3597
tony added a commit to tony/cv that referenced this issue Sep 5, 2022
See also: https://yarnpkg.com/getting-started/migration

Squashed:

yarn set version berry (3.0 -> 3.1+) to fix ERR_STREAM_PREMATURE_CLOSE

In our case this bumped to 3.2.3

See also: yarnpkg/berry#3597
pirelenito added a commit to Mojang/ore-ui that referenced this issue Oct 25, 2022
This fixes an issue I had locally when running `yarn`:

```
➤ YN0001: │ Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close
    at new NodeError (node:internal/errors:387:5)
    at PassThrough.onclose (node:internal/streams/end-of-stream:142:30)
    at PassThrough.emit (node:events:513:28)
    at emitCloseNT (node:internal/streams/destroy:132:10)
    at process.processTicksAndRejections (node:internal/process/task_queues:81:21)
➤ YN0000: └ Completed in 0s 686ms
➤ YN0000: Failed with errors in 0s 820ms
```

More info at: yarnpkg/berry#3597 (comment)
pirelenito added a commit to Mojang/ore-ui that referenced this issue Nov 1, 2022
This fixes an issue I had locally when running `yarn`:

```
➤ YN0001: │ Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close
    at new NodeError (node:internal/errors:387:5)
    at PassThrough.onclose (node:internal/streams/end-of-stream:142:30)
    at PassThrough.emit (node:events:513:28)
    at emitCloseNT (node:internal/streams/destroy:132:10)
    at process.processTicksAndRejections (node:internal/process/task_queues:81:21)
➤ YN0000: └ Completed in 0s 686ms
➤ YN0000: Failed with errors in 0s 820ms
```

More info at: yarnpkg/berry#3597 (comment)
@sk22
Copy link

sk22 commented Nov 3, 2022

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!

tony added a commit to tony/cv that referenced this issue Dec 17, 2022
See also: https://yarnpkg.com/getting-started/migration

Squashed:

yarn set version berry (3.0 -> 3.1+) to fix ERR_STREAM_PREMATURE_CLOSE

In our case this bumped to 3.2.3

See also: yarnpkg/berry#3597
petermetz added a commit to petermetz/dci-lint that referenced this issue Dec 20, 2022
The issue that this fixes is that on NodeJS v18.x LTS Yarn started
crashing with the following error on the CI while trying to install the
dependencies for the project:

 YN0001: │ Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close
      at new NodeError (node:internal/errors:393:5)
      at PassThrough.onclose (node:internal/streams/end-of-stream:142:30)
      at PassThrough.emit (node:events:513:28)
      at emitCloseNT (node:internal/streams/destroy:132:10)
      at process.processTicksAndRejections (node:internal/process/task_queues:81:21)

The fix was done based on the suggestion here:
yarnpkg/berry#3597 (comment)

Signed-off-by: Peter Somogyvari <peter.metz@unarin.com>
@jeffrafter
Copy link

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.

tony added a commit to tony/cv that referenced this issue Nov 14, 2023
See also: https://yarnpkg.com/getting-started/migration

Squashed:

yarn set version berry (3.0 -> 3.1+) to fix ERR_STREAM_PREMATURE_CLOSE

In our case this bumped to 3.2.3

See also: yarnpkg/berry#3597
tony added a commit to tony/cv that referenced this issue Nov 14, 2023
See also: https://yarnpkg.com/getting-started/migration

Squashed:

yarn set version berry (3.0 -> 3.1+) to fix ERR_STREAM_PREMATURE_CLOSE

In our case this bumped to 3.2.3

See also: yarnpkg/berry#3597
tony added a commit to tony/cv that referenced this issue Nov 15, 2023
See also: https://yarnpkg.com/getting-started/migration

Squashed:

yarn set version berry (3.0 -> 3.1+) to fix ERR_STREAM_PREMATURE_CLOSE

In our case this bumped to 3.2.3

See also: yarnpkg/berry#3597
tony added a commit to tony/cv that referenced this issue Nov 18, 2023
yarn set version 4.0.2

See also:
- https://yarnpkg.com/getting-started/migration
- https://yarnpkg.com/blog/release/4.0#installing-yarn

Squashed:

yarn set version berry (3.0 -> 3.1+) to fix ERR_STREAM_PREMATURE_CLOSE

In our case this bumped to 3.2.3

See also: yarnpkg/berry#3597
tony added a commit to tony/cv that referenced this issue Nov 18, 2023
yarn set version 4.0.2

See also:
- https://yarnpkg.com/getting-started/migration
- https://yarnpkg.com/blog/release/4.0#installing-yarn

Squashed:

yarn set version berry (3.0 -> 3.1+) to fix ERR_STREAM_PREMATURE_CLOSE

In our case this bumped to 3.2.3

See also: yarnpkg/berry#3597
tony added a commit to tony/cv that referenced this issue Nov 19, 2023
yarn set version 4.0.2

See also:
- https://yarnpkg.com/getting-started/migration
- https://yarnpkg.com/blog/release/4.0#installing-yarn

Squashed:

yarn set version berry (3.0 -> 3.1+) to fix ERR_STREAM_PREMATURE_CLOSE

In our case this bumped to 3.2.3

See also: yarnpkg/berry#3597
tony added a commit to tony/cv that referenced this issue Nov 19, 2023
yarn set version 4.0.2

See also:
- https://yarnpkg.com/getting-started/migration
- https://yarnpkg.com/blog/release/4.0#installing-yarn

Squashed:

yarn set version berry (3.0 -> 3.1+) to fix ERR_STREAM_PREMATURE_CLOSE

In our case this bumped to 3.2.3

See also: yarnpkg/berry#3597
tony added a commit to tony/cv that referenced this issue Nov 19, 2023
yarn set version 4.0.2

See also:
- https://yarnpkg.com/getting-started/migration
- https://yarnpkg.com/blog/release/4.0#installing-yarn

Squashed:

yarn set version berry (3.0 -> 3.1+) to fix ERR_STREAM_PREMATURE_CLOSE

In our case this bumped to 3.2.3

See also: yarnpkg/berry#3597
@sideshowbarker
Copy link

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 substrate-developer-hub/substrate-front-end-template#213 (comment))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upholded Real issues without formal reproduction
Projects
None yet
Development

Successfully merging a pull request may close this issue.