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.

contentful.getEntries() throws "Error: unexpected end of file at Zlib._handle.onerror (zlib.js:370:17)"

See original GitHub issue
  • Node Version: v6.9.4
  • Npm Version: 3.10.10
  • Platform: Linux 2109406ca117 4.4.16-boot2docker #1 SMP Fri Jul 29 00:13:24 UTC 2016 x86_64 GNU/Linux (Official debian:jessie-slim image from https://hub.docker.com/_/debian/)
  • Package Version: contentful@3.8.0

I am building within a Docker container pulled from the official debian:jessie-slim image, with Node v6.9.4 installed from http://deb.nodesource.com/node_6.x. I have been getting the following error on on ~90% builds:

root@2109406ca117:/investors# node app.js
events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: unexpected end of file
    at Zlib._handle.onerror (zlib.js:370:17)

The simplest code to reproduce this issue is below; interestingly, when the client.getContentTypes() call is removed, the error occurs with noticeably less frequency:

const contentful = require('contentful');

let client = contentful.createClient({
  accessToken: '',
  space: ''
});

client.getContentTypes().then(values => {
  client.getEntries({content_type: 'page'}).then(entries => console.log(entries));
});

From what I can tell, this seems to be an issue when chunks of data are dropped from gzipped responses and/or gzip response aren’t properly deflated. This would seem to align with the reduced error rate when the additional API call is removed. Here are a few issues that reported similar issues, with fixes referenced:

Some solutions have included more lenient gzip decompression, and providing an option to disable gzip.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
Khaledgarbayacommented, Jan 31, 2017

@andrewodri any time, I will close this issue for and feel free to create a new issue whenever you have a problem to report

2reactions
Khaledgarbayacommented, Jan 27, 2017

Hi @andrewodri , This is really weird I never seen this happening, I will try to reproduce this using Docker and come back to you asap, but mostly could be related to axios. Best, Khaled

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - Error: unexpected end of file at Zlib._handle.onerror ...
I am new in Node.js. when I decompressed input.txt.gz got an error. this is the error. Error: unexpected end of file at Zlib._handle.onerror...
Read more >
Errors | Contentful
HTTP status code Error code Description 401 Unauthorized AccessTokenInvalid The authorization token was invalid. 422 Unprocessable Entity UnknownField The triggered query references an unknown... 422 Unprocessable...
Read more >
Linked entries and assets in Contentful
Linked assets and entries in Contentful are a mystery no more! Let's explore how to work with links in the REST and GraphQP...
Read more >
Content Management API | Contentful
Contentful's Content Management API (CMA) helps you manage content in your spaces | Authentication | API rate limits | Spaces | Environments |...
Read more >
Getting Started with Contentful and JavaScript
This article details how to retrieve entries using the JavaScript CDA client library | Authentication | Setting up the client | Request and...
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