mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -05:00
A modern runtime for JavaScript and TypeScript.
https://deno.com/
b7c2902c97
When `worker.terminate()` is called, the spec requires that the corresponding port message queue is emptied, so no messages can be received after the call, even if they were sent from the worker before it was terminated. The spec doesn't require this of `self.close()`, and since Deno uses different channels to send messages and to notify that the worker was closed, messages might still arrive after the worker is known to be closed, which are currently being dropped. This change fixes that. The fix involves two parts: one on the JS side and one on the Rust side. The JS side was using the `#terminated` flag to keep track of whether the worker is known to be closed, without distinguishing whether further messages should be dropped or not. This PR changes that flag to an enum `#state`, which can be one of `"RUNNING"`, `"CLOSED"` or `"TERMINATED"`. The Rust side was removing the `WorkerThread` struct from the workers table when a close control was received, regardless of whether there were any messages left to read, which made any subsequent calls to `op_host_recv_message` to return `Ok(None)`, as if there were no more mesasges. This change instead waits for both a close control and for the message channel's sender to be closed before the worker thread is removed from the table. |
||
---|---|---|
.cargo | ||
.devcontainer | ||
.github | ||
bench_util | ||
cli | ||
core | ||
docs | ||
ext | ||
runtime | ||
test_ffi | ||
test_util | ||
third_party@084660078b | ||
tools | ||
.dlint.json | ||
.dprint.json | ||
.editorconfig | ||
.gitattributes | ||
.gitignore | ||
.gitmodules | ||
.rustfmt.toml | ||
Cargo.lock | ||
Cargo.toml | ||
CODE_OF_CONDUCT.md | ||
LICENSE.md | ||
README.md | ||
Releases.md |
Deno
Deno is a simple, modern and secure runtime for JavaScript and TypeScript that uses V8 and is built in Rust.
Features
- Secure by default. No file, network, or environment access, unless explicitly enabled.
- Supports TypeScript out of the box.
- Ships only a single executable file.
- Built-in utilities like a dependency inspector (deno info) and a code formatter (deno fmt).
- Set of reviewed standard modules that are guaranteed to work with Deno.
Install
Shell (Mac, Linux):
curl -fsSL https://deno.land/x/install/install.sh | sh
PowerShell (Windows):
iwr https://deno.land/x/install/install.ps1 -useb | iex
Homebrew (Mac):
brew install deno
Chocolatey (Windows):
choco install deno
Scoop (Windows):
scoop install deno
Build and install from source using Cargo:
cargo install deno --locked
See deno_install and releases for other options.
Getting Started
Try running a simple program:
deno run https://deno.land/std/examples/welcome.ts
Or a more complex one:
const listener = Deno.listen({ port: 8000 });
console.log("http://localhost:8000/");
for await (const conn of listener) {
serve(conn);
}
async function serve(conn: Deno.Conn) {
for await (const { respondWith } of Deno.serveHttp(conn)) {
respondWith(new Response("Hello world"));
}
}
You can find a deeper introduction, examples, and environment setup guides in the manual.
The complete API reference is available at the runtime documentation.
Contributing
We appreciate your help!
To contribute, please read our contributing instructions.