mirror of
https://github.com/kikootwo/ReadMeABook.git
synced 2026-06-03 04:40:09 +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 {
|
||||
data: {
|
||||
pipe: (dest: EventEmitter) => {
|
||||
// Emit synchronously to avoid race condition with download timeout
|
||||
setImmediate(() => dest.emit('finish'));
|
||||
// Use microtask to emit before timers run (avoids race with download timeout)
|
||||
queueMicrotask(() => dest.emit('finish'));
|
||||
return dest;
|
||||
},
|
||||
},
|
||||
@@ -193,8 +193,8 @@ describe('E-book sidecar', () => {
|
||||
return {
|
||||
data: {
|
||||
pipe: (dest: EventEmitter) => {
|
||||
// Emit synchronously to avoid race condition with download timeout
|
||||
setImmediate(() => dest.emit('finish'));
|
||||
// Use microtask to emit before timers run (avoids race with download timeout)
|
||||
queueMicrotask(() => dest.emit('finish'));
|
||||
return dest;
|
||||
},
|
||||
},
|
||||
@@ -337,8 +337,8 @@ describe('E-book sidecar', () => {
|
||||
return {
|
||||
data: {
|
||||
pipe: (dest: EventEmitter) => {
|
||||
// Emit synchronously to avoid race condition with download timeout
|
||||
setImmediate(() => dest.emit('finish'));
|
||||
// Use microtask to emit before timers run (avoids race with download timeout)
|
||||
queueMicrotask(() => dest.emit('finish'));
|
||||
return dest;
|
||||
},
|
||||
},
|
||||
@@ -622,8 +622,8 @@ describe('E-book sidecar', () => {
|
||||
return {
|
||||
data: {
|
||||
pipe: (dest: EventEmitter) => {
|
||||
// Emit synchronously to avoid race condition with download timeout
|
||||
setImmediate(() => dest.emit('finish'));
|
||||
// Use microtask to emit before timers run (avoids race with download timeout)
|
||||
queueMicrotask(() => dest.emit('finish'));
|
||||
return dest;
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user