FredKSchott / FredKSchott/rollup-plugin-polyfill-node

Zlib binding of error code does not seem to work properly

Open
#70 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
193
Forks
60
PR merge metrics
No merged PRs in 30d

Description

Using Buffer and zlib from this rollup-plugin-polyfill-node package

In zlib.js polyfill, when an error occurs, zlib is supposed to emit and error. Related code below:

```js
this._binding.onerror = function(message, errno) {
// there is no way to cleanly recover.
// continuing only obscures problems.
self._binding = null;
self._hadError = true;

var error = new Error(message);
error.errno = errno;
error.code = binding.codes[errno];
self.emit('error', error);
};
```

But it seems that `binding.codes` is undefined, and an uncaught TypeError is thrown instead:

```js
zlib.inflateRawSync(Buffer.from(""))

index.js:5 Uncaught TypeError: Cannot read properties of undefined (reading '-5')
at Zlib._binding.onerror (index.js:5:35)
at Zlib$1._error (index.js:5:35)
at Zlib$1._write (index.js:5:35)
at Zlib$1.writeSync (index.js:5:35)
at Zlib._processChunk (index.js:5:35)
at zlibBufferSync (index.js:5:35)
at Object.inflateRawSync (index.js:5:35)
at :1:6
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.