question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ZlibError when calling publish

See original GitHub issue

When we’re trying to publish our packages we are getting the error:

ZlibError: zlib: Cannot read property 'length' of null

Expected Behavior

It should publish the packages with no errors.

Current Behavior

It updates all the packages.json versions but DOES NOT publish them to the registry.

Possible Solution

Unknown?

Steps to Reproduce (for bugs)

Call npx lerna publish

Your Environment

Mac OS El Capitan 10.11.5 NPM version: 5.6.0 Node version: 9.2.1 Lerna version: 3.16.4

This is the full output of the log when we call npx lerna publish --loglevel verbose

lerna info execute Skipping releases
lerna verb git [ 'commit',
lerna verb git   '-F',
lerna verb git   '/private/var/folders/r_/t905430x1zvd1sgymm76t6p51b940m/T/bb79cbbe-dbe2-4a40-bbf6-8368b1b00437/lerna-commit.txt' ]
lerna verb git [ 'tag', '@fui/fui-button@1.3.0', '-m', '@fui/fui-button@1.3.0' ]
lerna verb git [ 'tag',
lerna verb git   '@fui/fui-buttons@1.3.0',
lerna verb git   '-m',
lerna verb git   '@fui/fui-buttons@1.3.0' ]
lerna verb git [ 'tag',
lerna verb git   '@fui/fui-checkbox@1.3.0',
lerna verb git   '-m',
lerna verb git   '@fui/fui-checkbox@1.3.0' ]
lerna verb git [ 'tag', '@fui/fui-form@1.3.0', '-m', '@fui/fui-form@1.3.0' ]
lerna verb git [ 'tag', '@fui/fui-forms@1.3.0', '-m', '@fui/fui-forms@1.3.0' ]
lerna verb git [ 'tag', '@fui/fui-radio@1.3.0', '-m', '@fui/fui-radio@1.3.0' ]
lerna verb git [ 'tag', '@fui/fui-select@1.3.0', '-m', '@fui/fui-select@1.3.0' ]
lerna verb git [ 'tag', '@fui/fui-switch@1.3.0', '-m', '@fui/fui-switch@1.3.0' ]
lerna verb git [ 'tag',
lerna verb git   '@fui/fui-text-field@1.3.0',
lerna verb git   '-m',
lerna verb git   '@fui/fui-text-field@1.3.0' ]
lerna verb git [ 'tag', '@fui/fui-core@4.4.0', '-m', '@fui/fui-core@4.4.0' ]
lerna verb git [ 'tag', '@fui/fui@4.4.0', '-m', '@fui/fui@4.4.0' ]
lerna info git Pushing tags...
lerna info publish Publishing packages to npm...
lerna notice Skipping all user and access validation due to third-party registry
lerna notice Make sure you're authenticated properly ¯\_(ツ)_/¯
lerna verb getCurrentSHA f6328967d0453c363a0d22d8d99f07f62da4ffad
lerna verb pack-directory packages/components/buttons/fui-button
lerna verb pack-directory packages/components/forms/fui-checkbox
lerna verb pack-directory packages/components/forms/fui-form
lerna verb pack-directory packages/components/forms/fui-radio
lerna verb pack-directory packages/components/forms/fui-select
lerna verb pack-directory packages/components/forms/fui-switch
lerna verb pack-directory packages/components/forms/fui-text-field
lerna verb pack-directory packages/fui-core
events.js:136
      throw er; // Unhandled 'error' event
      ^

ZlibError: zlib: Cannot read property 'length' of null
    at Gzip.Zlib.(anonymous function) (/Users/cameron.drysdale/Projects/fui/node_modules/minizlib/index.js:126:21)
    at Gzip.write (/Users/cameron.drysdale/Projects/fui/node_modules/minizlib/index.js:247:21)
    at Object.source.on.chunk (/Users/cameron.drysdale/Projects/fui/node_modules/tar/lib/pack.js:340:18)
    at Object.emit (events.js:159:13)
    at Object.emit (/Users/cameron.drysdale/Projects/fui/node_modules/minipass/index.js:308:25)
    at Object.write (/Users/cameron.drysdale/Projects/fui/node_modules/minipass/index.js:102:17)
    at Object.[onread] (/Users/cameron.drysdale/Projects/fui/node_modules/tar/lib/write-entry.js:263:10)
    at fs.read (/Users/cameron.drysdale/Projects/fui/node_modules/tar/lib/write-entry.js:220:19)
    at FSReqWrap.wrapper [as oncomplete] (fs.js:676:17)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13

github_iconTop GitHub Comments

19reactions
NMinhNguyencommented, Jul 1, 2020

@phun-ky apologies for the late response. I had seen this issue before when searching for similar problems since upgrading from Lerna v2 to v3, and I actually managed to solve it but forgot to reply here. If you’re using Yarn, then add this as a Yarn resolution to your root package.json:

{
  "resolutions": {
    "npm-packlist": "1.1.12"
  }
}

The way I found this was we were using npm pack (similarly to https://reactjs.org/blog/2017/12/15/improving-the-repository-infrastructure.html#simulating-package-publishing) and it would never fail, however our publishes would fail very very frequently since upgrading to Lerna 3. It’s been a while so I don’t remember the full details now, but I think what happened was I looked at what npm pack did under the hood and it turned out it was using this npm-packlist dependency and an older version than what was introduced in Lerna v3. Since pinning down npm-packlist we haven’t had a single failure (and before we’d sometimes get 3-5 in a row). Hope this helps!

Another thing you can do is defer git push until after a succesful publish:

npx lerna version --no-push --yes
npx lerna publish from-git --yes
# See https://github.com/lerna/lerna/blob/ea6ec639560ce71d9df8cbd7eef2d416e71f5442/commands/version/lib/git-push.js#L11
git push --follow-tags --no-verify origin master
2reactions
carsonfarmercommented, Jul 1, 2020

The above worked for us just now. Thank you @NMinhNguyen 🙏

Read more comments on GitHub >

github_iconTop Results From Across the Web

zlib.error: Error -3 while decompressing: incorrect header check
You have this error: zlib.error: Error -3 while decompressing: incorrect header check. Which is most likely because you are trying to check headers...
Read more >
Resolve the publish operation error in Amazon SNS - AWS
The error happens when I'm using a subnet, and I try to publish my SNS ... If you receive an authorization error when...
Read more >
Content Release: Patches for Windows published 2022-11-18
There are no other sites on that page that show a zLib error. ... Actually, when the tech called me, the auto-update had...
Read more >
zlib error webkit - Ask Ubuntu
zlib error webkit ... may set the environment variables ZLIB_CFLAGS and ZLIB_LIBS to avoid the need to call pkg-config. ... Post Your Answer...
Read more >
First Zlib error, then infinite loading, now I can't even uninstall...
Community subreddit for GTA Online & GTA V - Published & Developed by Rockstar Games. ... r/GTAV - The map of gta 5...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found