Skip to content

Commit

Permalink
add unit test for nodejs#3410
Browse files Browse the repository at this point in the history
  • Loading branch information
Uzlopak committed Aug 23, 2024
1 parent 6b1b3c4 commit ed52ccb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/issue-3410.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict'

const { test } = require('node:test')
const { eventLoopBlocker } = require('./utils/event-loop-blocker')
const { Agent, fetch, setGlobalDispatcher } = require('..')

test('https://github.com/nodejs/undici/issues/3356', async (t) => {
const connectTimeout = 2000
setGlobalDispatcher(new Agent({ connectTimeout }))

const fetchPromise = fetch('http://www.example.org/')

eventLoopBlocker(3000)

await fetchPromise
})
10 changes: 10 additions & 0 deletions test/utils/event-loop-blocker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict'

function eventLoopBlocker (ms) {
const nil = new Int32Array(new SharedArrayBuffer(4))
Atomics.wait(nil, 0, 0, ms)
}

module.exports = {
eventLoopBlocker
}

0 comments on commit ed52ccb

Please sign in to comment.