summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/zlib.js13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/zlib.js b/lib/zlib.js
index 6fb7696849..68d06fa93f 100644
--- a/lib/zlib.js
+++ b/lib/zlib.js
@@ -42,6 +42,7 @@ const {
Buffer,
kMaxLength
} = require('buffer');
+const { owner_symbol } = require('internal/async_hooks').symbols;
const constants = process.binding('constants').zlib;
const {
@@ -143,7 +144,7 @@ function zlibBufferSync(engine, buffer) {
}
function zlibOnError(message, errno) {
- var self = this.jsref;
+ var self = this[owner_symbol];
// there is no way to cleanly recover.
// continuing only obscures problems.
_close(self);
@@ -289,7 +290,8 @@ function Zlib(opts, mode) {
Transform.call(this, opts);
this.bytesWritten = 0;
this._handle = new binding.Zlib(mode);
- this._handle.jsref = this; // Used by processCallback() and zlibOnError()
+ // Used by processCallback() and zlibOnError()
+ this._handle[owner_symbol] = this;
this._handle.onerror = zlibOnError;
this._hadError = false;
this._writeState = new Uint32Array(2);
@@ -717,6 +719,13 @@ function createProperty(ctor) {
};
}
+// Legacy alias on the C++ wrapper object. This is not public API, so we may
+// want to runtime-deprecate it at some point. There's no hurry, though.
+Object.defineProperty(binding.Zlib.prototype, 'jsref', {
+ get() { return this[owner_symbol]; },
+ set(v) { return this[owner_symbol] = v; }
+});
+
module.exports = {
Deflate,
Inflate,