0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 17:34:47 -05:00

fix(cli): actually stabilize Deno.shutdown() (#9181)

This commit is contained in:
Bert Belder 2021-01-19 20:11:08 -08:00 committed by GitHub
parent 9312d48e69
commit b0132e8f90
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 32 deletions

View file

@ -515,8 +515,6 @@ unitTest(
unitTest( unitTest(
{ {
// FIXME(bartlomieju)
ignore: true,
perms: { net: true }, perms: { net: true },
}, },
async function netCloseWriteSuccess() { async function netCloseWriteSuccess() {
@ -537,36 +535,11 @@ unitTest(
assertEquals(1, buf[0]); assertEquals(1, buf[0]);
assertEquals(2, buf[1]); assertEquals(2, buf[1]);
assertEquals(3, buf[2]); assertEquals(3, buf[2]);
// Check write should be closed // Verify that the write end of the socket is closed.
// TODO(piscisaureus): assert that thrown error is of a specific type.
await assertThrowsAsync(async () => { await assertThrowsAsync(async () => {
await conn.write(new Uint8Array([1, 2, 3])); await conn.write(new Uint8Array([1, 2, 3]));
}, Deno.errors.BrokenPipe);
closeDeferred.resolve();
listener.close();
conn.close();
},
);
unitTest(
{
// FIXME(bartlomieju)
ignore: true,
perms: { net: true },
},
async function netDoubleCloseWrite() {
const addr = { hostname: "127.0.0.1", port: 3500 };
const listener = Deno.listen(addr);
const closeDeferred = deferred();
listener.accept().then(async (conn) => {
await closeDeferred;
conn.close();
}); });
const conn = await Deno.connect(addr);
conn.closeWrite(); // closing write
assertThrows(() => {
// Duplicated close should throw error
conn.closeWrite();
}, Deno.errors.NotConnected);
closeDeferred.resolve(); closeDeferred.resolve();
listener.close(); listener.close();
conn.close(); conn.close();

View file

@ -346,10 +346,7 @@ async fn op_shutdown(
args: Value, args: Value,
_zero_copy: BufVec, _zero_copy: BufVec,
) -> Result<Value, AnyError> { ) -> Result<Value, AnyError> {
super::check_unstable2(&state, "Deno.shutdown");
let args: ShutdownArgs = serde_json::from_value(args)?; let args: ShutdownArgs = serde_json::from_value(args)?;
let rid = args.rid as u32; let rid = args.rid as u32;
let resource = state let resource = state