@@ -42,6 +42,7 @@ const {
4242 Buffer,
4343 kMaxLength
4444} = require ( 'buffer' ) ;
45+ const { owner_symbol } = require ( 'internal/async_hooks' ) . symbols ;
4546
4647const constants = process . binding ( 'constants' ) . zlib ;
4748const {
@@ -143,7 +144,7 @@ function zlibBufferSync(engine, buffer) {
143144}
144145
145146function zlibOnError ( message , errno ) {
146- var self = this . jsref ;
147+ var self = this [ owner_symbol ] ;
147148 // there is no way to cleanly recover.
148149 // continuing only obscures problems.
149150 _close ( self ) ;
@@ -289,7 +290,8 @@ function Zlib(opts, mode) {
289290 Transform . call ( this , opts ) ;
290291 this . bytesWritten = 0 ;
291292 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 ;
293295 this . _handle . onerror = zlibOnError ;
294296 this . _hadError = false ;
295297 this . _writeState = new Uint32Array ( 2 ) ;
@@ -717,6 +719,13 @@ function createProperty(ctor) {
717719 } ;
718720}
719721
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+
720729module . exports = {
721730 Deflate,
722731 Inflate,
0 commit comments