File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -383,16 +383,23 @@ export class Query<
383383 meta : this . meta ,
384384 }
385385
386- Object . defineProperty ( queryFnContext , 'signal' , {
387- enumerable : true ,
388- get : ( ) => {
389- if ( abortController ) {
390- this . abortSignalConsumed = true
391- return abortController . signal
392- }
393- return undefined
394- } ,
395- } )
386+ // Adds an enumerable signal property to the object that
387+ // which sets abortSignalConsumed to true when the signal
388+ // is read.
389+ const addSignalProperty = ( object : unknown ) => {
390+ Object . defineProperty ( object , 'signal' , {
391+ enumerable : true ,
392+ get : ( ) => {
393+ if ( abortController ) {
394+ this . abortSignalConsumed = true
395+ return abortController . signal
396+ }
397+ return undefined
398+ } ,
399+ } )
400+ }
401+
402+ addSignalProperty ( queryFnContext )
396403
397404 // Create fetch function
398405 const fetchFn = ( ) => {
@@ -413,16 +420,7 @@ export class Query<
413420 meta : this . meta ,
414421 }
415422
416- Object . defineProperty ( context , 'signal' , {
417- enumerable : true ,
418- get : ( ) => {
419- if ( abortController ) {
420- this . abortSignalConsumed = true
421- return abortController . signal
422- }
423- return undefined
424- } ,
425- } )
423+ addSignalProperty ( context )
426424
427425 if ( this . options . behavior ?. onFetch ) {
428426 this . options . behavior ?. onFetch ( context )
You can’t perform that action at this time.
0 commit comments