GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — quic: fix wake up blob · nodejs/node@009e376

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal
    • blob.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/blob.js‎

Copy file name to clipboardExpand all lines: lib/internal/blob.js
+15-4Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -469,9 +469,13 @@ function createBlobReaderStream(reader) {
469469
this.pendingPulls = [];
470470
// Lazily register a wakeup callback that the C++ side can invoke
471471
// when new data is available after a STATUS_BLOCK.
472+
let immediate;
472473
this.wakeup = () => {
473474
if (this.pendingPulls.length > 0) {
474-
this.readNext(c);
475+
immediate ??= setImmediate(() => {
476+
immediate = undefined;
477+
this.readNext(c);
478+
});
475479
}
476480
};
477481
},
@@ -571,7 +575,15 @@ const kMaxBatchChunks = 16;
571575
async function* createBlobReaderIterable(reader, options = kEmptyObject) {
572576
const { getReadError } = options;
573577
let wakeup = PromiseWithResolvers();
574-
reader.setWakeup(wakeup.resolve);
578+
let immediate;
579+
let fin = false;
580+
reader.setWakeup((setfin) => {
581+
fin ||= setfin;
582+
immediate ??= setImmediate(() => {
583+
immediate = undefined;
584+
wakeup.resolve?.();
585+
});
586+
});
575587

576588
try {
577589
while (true) {
@@ -616,9 +628,8 @@ async function* createBlobReaderIterable(reader, options = kEmptyObject) {
616628
if (error) throw error;
617629

618630
if (blocked) {
619-
const fin = await wakeup.promise;
631+
await wakeup.promise;
620632
wakeup = PromiseWithResolvers();
621-
reader.setWakeup(wakeup.resolve);
622633
// If the wakeup was triggered by FIN (EndReadable), the DataQueue
623634
// is capped. Continue the loop to pull again -- the next pull will
624635
// return EOS. Without this, a race between the data notification

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.