Skip to content

Commit e99e8f4

Browse files
authored
chore: fix socket test (#2756)
Depending on timing either error can be thrown.
1 parent ab51119 commit e99e8f4

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

packages/transport-tcp/test/socket-to-conn.spec.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -478,12 +478,16 @@ describe('socket-to-conn', () => {
478478
expect(serverTimedOut.promise).to.eventually.be.true(),
479479

480480
// server socket was closed for reading and writing
481-
expect(serverClosed.promise).to.eventually.be.true(),
482-
483-
// client connection was closed abruptly
484-
expect(clientError.promise).to.eventually.have.property('code', 'ECONNRESET')
481+
expect(serverClosed.promise).to.eventually.be.true()
485482
])
486483

484+
const err = await clientError.promise
485+
486+
// can be either error depending on platform and timing
487+
if (err.code !== 'ECONNRESET' && err.code !== 'EPIPE') {
488+
expect.fail('client connection did not close abruptly')
489+
}
490+
487491
// server socket should no longer be writable
488492
expect(serverSocket.writable).to.be.false()
489493

0 commit comments

Comments
 (0)