@@ -42,6 +42,7 @@ const { |
42 | 42 | Buffer, |
43 | 43 | kMaxLength |
44 | 44 | } = require('buffer'); |
| 45 | +const { owner_symbol } = require('internal/async_hooks').symbols; |
45 | 46 |
|
46 | 47 | const constants = process.binding('constants').zlib; |
47 | 48 | const { |
@@ -143,7 +144,7 @@ function zlibBufferSync(engine, buffer) { |
143 | 144 | } |
144 | 145 |
|
145 | 146 | function zlibOnError(message, errno) { |
146 | | - var self = this.jsref; |
| 147 | + var self = this[owner_symbol]; |
147 | 148 | // there is no way to cleanly recover. |
148 | 149 | // continuing only obscures problems. |
149 | 150 | _close(self); |
@@ -289,7 +290,8 @@ function Zlib(opts, mode) { |
289 | 290 | Transform.call(this, opts); |
290 | 291 | this.bytesWritten = 0; |
291 | 292 | this._handle = new binding.Zlib(mode); |
292 | | - this._handle.jsref = this; // Used by processCallback() and zlibOnError() |
| 293 | + // Used by processCallback() and zlibOnError() |
| 294 | + this._handle[owner_symbol] = this; |
293 | 295 | this._handle.onerror = zlibOnError; |
294 | 296 | this._hadError = false; |
295 | 297 | this._writeState = new Uint32Array(2); |
@@ -717,6 +719,13 @@ function createProperty(ctor) { |
717 | 719 | }; |
718 | 720 | } |
719 | 721 |
|
| 722 | +// Legacy alias on the C++ wrapper object. This is not public API, so we may |
| 723 | +// want to runtime-deprecate it at some point. There's no hurry, though. |
| 724 | +Object.defineProperty(binding.Zlib.prototype, 'jsref', { |
| 725 | + get() { return this[owner_symbol]; }, |
| 726 | + set(v) { return this[owner_symbol] = v; } |
| 727 | +}); |
| 728 | + |
720 | 729 | module.exports = { |
721 | 730 | Deflate, |
722 | 731 | Inflate, |
|