@@ -107,9 +107,14 @@ for (const proto of testProtos("tcp", "ipc", "inproc")) {
107107 } )
108108
109109 it ( "should release reference to context" , async function ( ) {
110- if ( process . env . SKIP_GC_TESTS ) {
110+ if ( process . env . SKIP_GC_TESTS === "true" ) {
111111 this . skip ( )
112112 }
113+ if ( global . gc === undefined ) {
114+ console . warn ( "gc is not exposed by the runtime" )
115+ this . skip ( )
116+ }
117+
113118 this . slow ( 200 )
114119
115120 const weak = require ( "weak-napi" ) as typeof import ( "weak-napi" )
@@ -124,14 +129,14 @@ for (const proto of testProtos("tcp", "ipc", "inproc")) {
124129 } )
125130 context = undefined
126131
127- global . gc ?. ( )
132+ global . gc ! ( )
128133 socket . connect ( uniqAddress ( proto ) )
129134 await socket . send ( Buffer . from ( "foo" ) )
130135 socket . close ( )
131136 }
132137
133138 await task ( )
134- global . gc ?. ( )
139+ global . gc ( )
135140 await new Promise ( resolve => {
136141 setTimeout ( resolve , 5 )
137142 } )
@@ -141,10 +146,11 @@ for (const proto of testProtos("tcp", "ipc", "inproc")) {
141146
142147 describe ( "in gc finalizer" , function ( ) {
143148 it ( "should release reference to context" , async function ( ) {
144- if ( process . env . SKIP_GC_TESTS ) {
149+ if ( process . env . SKIP_GC_TESTS === "true" ) {
145150 this . skip ( )
146151 }
147- if ( process . env . SKIP_GC_FINALIZER_TESTS ) {
152+ if ( global . gc === undefined ) {
153+ console . warn ( "gc is not exposed by the runtime" )
148154 this . skip ( )
149155 }
150156 this . slow ( 200 )
@@ -155,17 +161,17 @@ for (const proto of testProtos("tcp", "ipc", "inproc")) {
155161 const task = async ( ) => {
156162 let context : zmq . Context | undefined = new zmq . Context ( )
157163
158- new zmq . Dealer ( { context, linger : 0 } )
164+ const _dealer = new zmq . Dealer ( { context, linger : 0 } )
159165
160166 weak ( context , ( ) => {
161167 released = true
162168 } )
163169 context = undefined
164- global . gc ?. ( )
170+ global . gc ! ( )
165171 }
166172
167173 await task ( )
168- global . gc ?. ( )
174+ global . gc ( )
169175 await new Promise ( resolve => {
170176 setTimeout ( resolve , 5 )
171177 } )
0 commit comments