Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "fix: post request signal (#3354)" #3359

Merged
merged 1 commit into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions lib/api/api-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,6 @@ class RequestHandler extends AsyncResource {
}

onComplete (trailers) {
if (this.removeAbortListener) {
this.removeAbortListener()
this.removeAbortListener = null
}

util.parseHeaders(trailers, this.trailers)
this.res.push(null)
}
Expand Down
25 changes: 2 additions & 23 deletions test/request-signal.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,9 @@ test('post abort signal', async (t) => {

server.listen(0, async () => {
const ac = new AbortController()
const uresPromise = request(`http://0.0.0.0:${server.address().port}`, { signal: ac.signal })
const ures = await request(`http://0.0.0.0:${server.address().port}`, { signal: ac.signal })
ac.abort()

try {
const ures = await uresPromise
/* eslint-disable-next-line no-unused-vars */
for await (const chunk of ures.body) {
// Do nothing...
Expand All @@ -63,11 +61,9 @@ test('post abort signal w/ reason', async (t) => {
server.listen(0, async () => {
const ac = new AbortController()
const _err = new Error()
const uresPromise = request(`http://0.0.0.0:${server.address().port}`, { signal: ac.signal })
const ures = await request(`http://0.0.0.0:${server.address().port}`, { signal: ac.signal })
ac.abort(_err)

try {
const ures = await uresPromise
/* eslint-disable-next-line no-unused-vars */
for await (const chunk of ures.body) {
// Do nothing...
Expand All @@ -78,20 +74,3 @@ test('post abort signal w/ reason', async (t) => {
})
await t.completed
})

test('post abort signal after request completed', async (t) => {
t = tspl(t, { plan: 1 })

const server = createServer((req, res) => {
res.end('asd')
})
after(() => server.close())

server.listen(0, async () => {
const ac = new AbortController()
const ures = await request(`http://0.0.0.0:${server.address().port}`, { signal: ac.signal })
ac.abort()
t.equal(await ures.body.text(), 'asd')
})
await t.completed
})
Loading