You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constanySignal=require('any-signal')constuserController=newAbortController()consttimeoutController=newAbortController()constcombinedSignal=anySignal([userController.signal,timeoutController.signal])combinedSignal.addEventListener('abort',()=>console.log('Abort!'))// Abort after 1 secondconsttimeoutId=setTimeout(()=>timeoutController.abort(),1000)// The user or the timeout can now abort the actionawaitperformSomeAction({signal: combinedSignal})clearTimeout(timeoutId)
After all the lines are executed, there are still event handlers attached to userController.signal and timeoutController.signal. There is no code that clears them. It all works fine if userController and timeoutController both are garbage collected after clearTimeout.
Let's consider the following code, where an AbortController is long-lived, along with its AbortSignal.
On every call to load method, you'd add an event handler to this.shutdownController.signal. It never gets removed, which leads to some minor but very constant memory leak, as well as some annoying warnings, like libp2p/js-libp2p#900
Are you open to PRs fixing this?
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
Consider code in the README file:
After all the lines are executed, there are still event handlers attached to
userController.signal
andtimeoutController.signal
. There is no code that clears them. It all works fine ifuserController
andtimeoutController
both are garbage collected afterclearTimeout
.Let's consider the following code, where an AbortController is long-lived, along with its AbortSignal.
On every call to
load
method, you'd add an event handler tothis.shutdownController.signal
. It never gets removed, which leads to some minor but very constant memory leak, as well as some annoying warnings, like libp2p/js-libp2p#900Are you open to PRs fixing this?
The text was updated successfully, but these errors were encountered: