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
I was having trouble trying to close my ReadableStream after getting the metadata I needed. I wanted to dispose of it ASAP to clear any resources being held.
But calling ReadableStream.close() threw an error because the library was still holding onto a reader somewhere. (Inside strtok3 or peek-readable packages I presume)
I can solve this problem myself by using strtok3's fromWebStream() function to get a Tokenizer and then call Tokenizer.abort() as soon as parseTokenizer() returns with the metadata.
consttokenizer=fromWebStream(myReadableStream,{mimeType: 'audio/mpeg',path: filePath,size: fileSize});constmeta=awaitparseFromTokenizer(tokenizer,{skipCovers: true,skipPostHeaders: true},);awaittokenizer.abort();// Successfully closes the stream
But still, I was just wondering if it would make sense to support some kind of mechanism where the library calls Reader.releaseLock() when it's done parsing all the metadata it needs.
That would allow the supplier of the ReadableStream to do whatever they want with the stream after the metadata has been retrieved. They can choose to continue reading data (if it has more to read) or they can close the stream without any errors because the lock is not being held.
Doing this would probably require changes in the strtok3 and peek-readable packages as well. So I understand it might be complicated. It would need to expose a function similar to abort() but softer.. something that can release the lock on the stream's reader. So maybe something like release() or cleanup()? And this functionality wouldn't have to be implemented by all sources.. only those that have resource locking like Web streams.
Do you have any thoughts on this? I'd be glad to lend a hand with some PRs across the packages if you feel like it makes sense.
The text was updated successfully, but these errors were encountered:
Good catch @georgevarghese185. To me it looks like a bug in music-metadata. There is a tokenizer.close() method which is not called, in that shall release the stream it reading from.
Is there an existing issue for this?
Feature description
I was having trouble trying to close my
ReadableStream
after getting the metadata I needed. I wanted to dispose of it ASAP to clear any resources being held.But calling
ReadableStream.close()
threw an error because the library was still holding onto a reader somewhere. (Insidestrtok3
orpeek-readable
packages I presume)I can solve this problem myself by using
strtok3
'sfromWebStream()
function to get aTokenizer
and then callTokenizer.abort()
as soon asparseTokenizer()
returns with the metadata.But still, I was just wondering if it would make sense to support some kind of mechanism where the library calls Reader.releaseLock() when it's done parsing all the metadata it needs.
That would allow the supplier of the
ReadableStream
to do whatever they want with the stream after the metadata has been retrieved. They can choose to continue reading data (if it has more to read) or they can close the stream without any errors because the lock is not being held.Doing this would probably require changes in the
strtok3
andpeek-readable
packages as well. So I understand it might be complicated. It would need to expose a function similar toabort()
but softer.. something that can release the lock on the stream's reader. So maybe something likerelease()
orcleanup()
? And this functionality wouldn't have to be implemented by all sources.. only those that have resource locking like Web streams.Do you have any thoughts on this? I'd be glad to lend a hand with some PRs across the packages if you feel like it makes sense.
The text was updated successfully, but these errors were encountered: