mirror of
https://github.com/kikootwo/ReadMeABook.git
synced 2026-06-02 20:30:10 +00:00
Replace setImmediate with queueMicrotask in tests
Updated ebook-scraper tests to use queueMicrotask instead of setImmediate for emitting 'finish' events. This change ensures microtasks run before timers, reducing race conditions with download timeouts.
This commit is contained in:
@@ -144,8 +144,8 @@ describe('E-book sidecar', () => {
|
|||||||
return {
|
return {
|
||||||
data: {
|
data: {
|
||||||
pipe: (dest: EventEmitter) => {
|
pipe: (dest: EventEmitter) => {
|
||||||
// Emit synchronously to avoid race condition with download timeout
|
// Use microtask to emit before timers run (avoids race with download timeout)
|
||||||
setImmediate(() => dest.emit('finish'));
|
queueMicrotask(() => dest.emit('finish'));
|
||||||
return dest;
|
return dest;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -193,8 +193,8 @@ describe('E-book sidecar', () => {
|
|||||||
return {
|
return {
|
||||||
data: {
|
data: {
|
||||||
pipe: (dest: EventEmitter) => {
|
pipe: (dest: EventEmitter) => {
|
||||||
// Emit synchronously to avoid race condition with download timeout
|
// Use microtask to emit before timers run (avoids race with download timeout)
|
||||||
setImmediate(() => dest.emit('finish'));
|
queueMicrotask(() => dest.emit('finish'));
|
||||||
return dest;
|
return dest;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -337,8 +337,8 @@ describe('E-book sidecar', () => {
|
|||||||
return {
|
return {
|
||||||
data: {
|
data: {
|
||||||
pipe: (dest: EventEmitter) => {
|
pipe: (dest: EventEmitter) => {
|
||||||
// Emit synchronously to avoid race condition with download timeout
|
// Use microtask to emit before timers run (avoids race with download timeout)
|
||||||
setImmediate(() => dest.emit('finish'));
|
queueMicrotask(() => dest.emit('finish'));
|
||||||
return dest;
|
return dest;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -622,8 +622,8 @@ describe('E-book sidecar', () => {
|
|||||||
return {
|
return {
|
||||||
data: {
|
data: {
|
||||||
pipe: (dest: EventEmitter) => {
|
pipe: (dest: EventEmitter) => {
|
||||||
// Emit synchronously to avoid race condition with download timeout
|
// Use microtask to emit before timers run (avoids race with download timeout)
|
||||||
setImmediate(() => dest.emit('finish'));
|
queueMicrotask(() => dest.emit('finish'));
|
||||||
return dest;
|
return dest;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user