fix: Data transfer stream backpressure from providers

This commit is contained in:
Christian 2023-10-30 11:43:20 +01:00 committed by GitHub
parent 9e14912c58
commit c76dc9cb2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -383,11 +383,6 @@ export const createPushController = handlerControllerFactory<Partial<PushHandler
} }
for (const item of payload) { for (const item of payload) {
/**
* This queues the given callback function to be executed in the next iteration
* of the event loop, immediately after the current operation completes.
*/
process.nextTick(async () => {
const { action, assetID } = item; const { action, assetID } = item;
if (!assetsStream) { if (!assetsStream) {
@ -404,7 +399,6 @@ export const createPushController = handlerControllerFactory<Partial<PushHandler
// We need to transform it back into a Buffer instance // We need to transform it back into a Buffer instance
const rawBuffer = item.data as unknown as { type: 'Buffer'; data: Uint8Array }; const rawBuffer = item.data as unknown as { type: 'Buffer'; data: Uint8Array };
const chunk = Buffer.from(rawBuffer.data); const chunk = Buffer.from(rawBuffer.data);
await writeAsync(this.assets[assetID].stream, chunk); await writeAsync(this.assets[assetID].stream, chunk);
} }
@ -420,7 +414,6 @@ export const createPushController = handlerControllerFactory<Partial<PushHandler
.end(); .end();
}); });
} }
});
} }
}, },