fix: ensure callback is called exactly once in StreamPositioner and WebMOpusMuxer

This commit is contained in:
NoLogicAlan committed 2026-10-17 03:20:57 +03:00
1 parent 6e1722b723
commit 5129ee5ecc
2 files changed
+12 -12

No files matched your search

+5 -7
View File
@@ -162,17 +162,15 @@ export class StreamPositioner extends Transform {
/** @param {Buffer} chunk @param {string} _enc @param {Function} cb @protected */
_transform(chunk, _enc, cb) {
let error = null;
try {
if (this._done) {
this.push(chunk);
return cb();
}
if (this._kind === "ogg") this._feedOgg(chunk);
if (this._done) this.push(chunk);
else if (this._kind === "ogg") this._feedOgg(chunk);
else this._feedWebm(chunk);
cb();
} catch (err) {
cb(err);
error = err;
}
cb(error);
}
/** @param {Function} cb @protected */
+7 -5
View File
@@ -252,26 +252,28 @@ export class WebMOpusMuxer extends Transform {
* @protected
*/
_transform(packet, _encoding, callback) {
let error = null;
try {
if (Buffer.isBuffer(packet) && packet.length > 0) {
this._addBlock(packet);
}
callback();
} catch (err) {
callback(err);
error = err;
}
callback(error);
}
/**
* @param {Function} callback
* @protected
*/
_final(callback) {
_flush(callback) {
let error = null;
try {
this._flushCluster();
callback();
} catch (err) {
callback(err);
error = err;
}
callback(error);
}
}