Node: invalid distance too far back

Created on 13 Sep 2018  Â·  19Comments  Â·  Source: nodejs/node

Hello,

I'm getting a invalid distance too far back error message with npm/yarn (see https://github.com/yarnpkg/yarn/issues/6357). It happens consistently and looks like a zlib error for corrupt data (?).

  • v10.9.0
  • FreeBSD dev.lan 10.3-RELEASE FreeBSD 10.3-RELEASE #0 r297264: Fri Mar 25 02:10:02 UTC 2016 [email protected]:/usr/obj/usr/src/sys/GENERIC amd64
  • Zlib
~/code/projects/amnesiabbpf/amnesiabbpf/frontend/ npm update webpack
npm ERR! code Z_DATA_ERROR
npm ERR! errno -3
npm ERR! invalid distance too far back

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/jcigar/.npm/_logs/2018-09-13T11_39_20_299Z-debug.log
~/code/projects/amnesiabbpf/amnesiabbpf/frontend/ more /home/jcigar/.npm/_logs/2018-09-13T11_39_20_299Z-debug.log
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'update',
1 verbose cli   'webpack' ]
2 info using [email protected]
3 info using [email protected]
4 verbose npm-session 0d2be4137d87cb91
5 verbose update computing outdated modules to update
6 silly mapToRegistry name webpack
7 silly mapToRegistry using default registry
8 silly mapToRegistry registry https://registry.npmjs.org/
9 silly mapToRegistry data { type: 'tag',
9 silly mapToRegistry   registry: true,
9 silly mapToRegistry   where: undefined,
9 silly mapToRegistry   raw: 'webpack',
9 silly mapToRegistry   name: 'webpack',
9 silly mapToRegistry   escapedName: 'webpack',
9 silly mapToRegistry   scope: undefined,
9 silly mapToRegistry   rawSpec: '',
9 silly mapToRegistry   saveSpec: null,
9 silly mapToRegistry   fetchSpec: 'latest',
9 silly mapToRegistry   gitRange: undefined,
9 silly mapToRegistry   gitCommittish: undefined,
9 silly mapToRegistry   hosted: undefined }
10 silly mapToRegistry uri https://registry.npmjs.org/webpack
11 verbose request uri https://registry.npmjs.org/webpack
12 verbose request no auth needed
13 info attempt registry request try #1 at 1:38:10 PM
14 verbose request id 81b3118c03482bfc
15 http request GET https://registry.npmjs.org/webpack
16 info retry will retry, error on last attempt: Error: invalid distance too far back
17 info attempt registry request try #2 at 1:38:20 PM
18 http request GET https://registry.npmjs.org/webpack
19 info retry will retry, error on last attempt: Error: invalid distance too far back
20 info attempt registry request try #3 at 1:39:20 PM
21 http request GET https://registry.npmjs.org/webpack
22 verbose stack Error: invalid distance too far back
22 verbose stack     at Zlib.zlibOnError [as onerror] (zlib.js:153:17)
23 verbose cwd /usr/home/jcigar/code/projects/amnesiabbpf/amnesiabbpf/frontend
24 verbose FreeBSD 10.3-RELEASE
25 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "update" "webpack"
26 verbose node v10.9.0
27 verbose npm  v6.4.0
28 error code Z_DATA_ERROR
29 error errno -3
30 error invalid distance too far back
31 verbose exit [ -3, true ]
freebsd zlib

Most helpful comment

The fix is to update your zlb. On Debian testing, as of now, 1.2.8 caused nodejs/npm to exhibit the fault while 1.2.11 did not.

All 19 comments

Downgrading from v10.9.0 to v8.11.4 fixed the issue.

this is with:

~/tmp/yarn/src/ pkg info node8
node8-8.11.4
Name           : node8
Version        : 8.11.4
Installed on   : Thu Sep 13 16:06:14 2018 CEST
Origin         : www/node8
Architecture   : FreeBSD:10:amd64
Prefix         : /usr/local
Categories     : www
Licenses       : MIT
Maintainer     : [email protected]
WWW            : https://nodejs.org/
Comment        : V8 JavaScript for client and server (8.x LTS)
Options        :
        BUNDLED_SSL    : on
        DOCS           : on
        NLS            : off
Shared Libs required:
        libcares.so.2
        libuv.so.1
Annotations    :
        FreeBSD_version: 1003000
        repo_type      : binary
        repository     : bebif
Flat size      : 27.0MiB
Description    :
Node.js is a JavaScript runtime built on Chrome's V8 JavaScript
engine. Node.js uses an event-driven, non-blocking I/O model that
makes it lightweight and efficient. Node.js' package ecosystem,
npm, is the largest ecosystem of open source libraries in the world.

WWW: https://nodejs.org/

ping @addaleax ... any ideas here?

@nodejs/zlib

@silenius Do you think you might be able to look at the file that decompression is failing on? Is this happening with every npm package you try to install?

@addaleax : yes, it is happening with every package

@silenius Are you behind a proxy? Can you check whether this only happens on FreeBSD or not? Do you think you might be able to look into what exactly the data is that is being passed to zlib here?

@addaleax I'm not behind a proxy. I just tested on a freshly installed 11.2-RELEASE and it works as expected, so I think it only happens on FreeBSD <= 10.3.

mmh apparently zlib has been upgraded in 10.4 (https://svnweb.freebsd.org/base?view=revision&revision=313796), so maybe it should work (unfortunately I don't have any 10.4 to test at the moment)

@silenius I think there’s a good chance that this would be a fix, yes. You can also try compiling Node.js from source, I think? We ship our own copy of zlib in our main tarball, so that could be unaffected by whatever bug you’re hitting?

I'm closing this issue as it works on "officially supported" FreeBSD releases (> 10.3).. thanks for your help and sorry for the noise (:

I'm getting this on OpenSuse Leap 42.3. I have no idea what I'm doing and was just playing around with a default project created with vue init webpack-simple my-vue-app and decided to delete node_modules to see if it could be recreated with vue install. Maybe it's the wrong install command?
Looking at the 7K+ line npm log file, you'd think I was compiling a kernel.

The fix is to update your zlb. On Debian testing, as of now, 1.2.8 caused nodejs/npm to exhibit the fault while 1.2.11 did not.

what do you mean by update zlib @smurfix ? doesn't it come as part of node itself? we're having this error and other random zlib errors regularly from node 11.9 on debian

Debian dislikes vendorized libraries and uses the system's libraries wherever possible.

In any case, I had that exact error last week and fixed it by changing nothing – except updating the system's zlib.

Updating zlib was what worked for me. Thanks.

How do I update zlib on a Synology?

How do I update zlib on a Synology?

Yes... how?

@Frenkie64 @paulsview
https://stackoverflow.com/questions/60288671/npm-install-on-synology-gives-zlib-invalid-distance-error

If you don't want to install entware you can find zlib.so.1.2.11 inside the entware package for your machine. Example for x86_64 : https://pkg.entware.net/binaries/x86-64/Packages.html

I used chmod 755 in lieu of chmod +x

Was this page helpful?
0 / 5 - 0 ratings