This commit repurposes `--unstable-node-globals` flag that was
deprecated
in https://github.com/denoland/deno/pull/29887 to switch out timers
implemention that is used.
Ie. using this flag cause `setTimeout`, `setInterval`, `clearTimeout`
and `clearInterval` globals to use functions from `node:timers`
module instead of the Web version.
This is also enabled using `DENO_COMPAT=1` env var.
TODO:
<s>make typechecking be conditional depending on this, most likely
requires
changes in our TS fork.</s> This has been deferred until Deno 3
Towards https://github.com/denoland/deno/issues/29703
---------
Signed-off-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: David Sherret <dsherret@users.noreply.github.com>
This commit updates V8 to version 14.0.0. This update brings
changes to Temporal support too, which is close to being stabilized.
---------
Co-authored-by: snek <snek@deno.com>
This commit adds `Deno.test.beforeAll`, `Deno.test.beforeEach`,
`Deno.test.afterAll` and `Deno.test.afterEach` APIs.
These APIs can be used to perform setup and teardown for test cases.
The API is similar to the Vitest API: https://vitest.dev/api/#setup-and-teardown,
with the main difference being that that `before*` hooks don't return a cleanup
function.
This is not a full-fledged and fully correct `require`/CJS support
for `node:worker_threads`, but unlocks certain scenarios that
were not working at all previously.
This commits adds `DENO_AUTO_SERVE` env var, that when specified
makes `deno run` behave like `deno serve` if the entrypoint satisfies
the `Deno.ServeDefaultExport` interface.
This removes the additional arguments on the function returned by
`Module.wrap`.
Allow libraries that overwrite this behavior (like `v8-code-cache`) to
work correctly.
---------
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
This commit removes "WorkerGlobalScope" global from the "global
middleware" that we use to provide different set of globals to
user code and npm packages.
This is done, by renaming "WebWorkerType" to "WorkerThreadType"
and introducing a "Node" variant - this variant is used when creating
a worker using "node:worker_threads" module. This worker does
not have a "WorkerGlobalScope" (because it's not a Web Worker)
and the regular Web Worker created using "new Worker" does have
it.
Ref https://github.com/denoland/deno/pull/27217
> `op_runtime_cpu_usage` can be optimized by accepting a `&mut [u32]`
instead of returning a serde tuple but it can be done as a follow up.
Accept a `&mut [u32]` instead of serde tuple for `op_runtime_cpu_usage`
and `op_runtime_memory_usage`
---------
Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
implement lazy(?) mode. an unconfigured jsruntime is created if
DENO_UNSTABLE_CONTROL_SOCK is present, and later passed into deno_runtime to be
configured and used.
This commit adds "deno_features" crate that contains definitions of all
unstable features in Deno.
Based on these definitions, both Rust and JS code is generated ensuring
that the two are always in sync.
In addition some of flag handling was rewritten to use the generated
definitions, instead of hand rolling these flag definitions.
---------
Co-authored-by: snek <snek@deno.com>
`import.meta.log` enables basic log filtering through
`env_logger`/`DENO_LOG`. Log levels are supported, and filenames can
also be used. for example: `DENO_LOG=ext:deno_http::00_serve.ts=warn`
This patches Temporal to support the `getTimeZoneTransition` method on
`ZonedDateTime`.
See https://github.com/denoland/deno/issues/27731.
Co-authored-by: printfn <printfn@users.noreply.github.com>
This commit adds an unstable lint plugin API.
Plugins are specified in the `deno.json` file under
`lint.plugins` option like so:
```
{
"lint": {
"plugins": [
"./plugins/my-plugin.ts",
"jsr:@deno/lint-plugin1",
"npm:@deno/lint-plugin2"
]
}
}
```
The API is considered unstable and might be subject
to changes in the future.
Plugin API was modelled after ESLint API for the
most part, but there are no guarantees for compatibility.
The AST format exposed to plugins is closely modelled
after the AST that `typescript-eslint` uses.
Lint plugins use the visitor pattern and can add
diagnostics like so:
```
export default {
name: "lint-plugin",
rules: {
"plugin-rule": {
create(context) {
return {
Identifier(node) {
if (node.name === "a") {
context.report({
node,
message: "should be b",
fix(fixer) {
return fixer.replaceText(node, "_b");
},
});
}
},
};
},
},
},
} satisfies Deno.lint.Plugin;
```
Besides reporting errors (diagnostics) plugins can provide
automatic fixes that use text replacement to apply changes.
---------
Co-authored-by: Marvin Hagemeister <marvin@deno.com>
Co-authored-by: David Sherret <dsherret@gmail.com>
Initial implementation of WebTransport client and server!
This is very unstable because the interface should eventually shift to
use hyper (h3 is on the [2025
roadmap](https://hyper.rs/contrib/roadmap/)) instead of manually messing
with the the protocol, which will enable integration with
Deno.serveHttp/etc and allow WebTransport over h2. This will also let us
expose multiplexing.
WebTransport stats will be a followup due to their complexity.
Fixes: https://github.com/denoland/deno/issues/9017
A QUIC endpoint is a UDP socket which multiplexes QUIC sessions, which
may be initiated in either direction. This PR exposes endpoints and
moves things around as needed.
Now that endpoints can be reused between client connections, we have a
way to share tls tickets between them and allow 0rtt. This interface
currently works by conditionally returning a promise.
Also cleaned up the rust op names, fixed some lingering problems in the
data transmission, and switched to explicit error types.
This PR extracts the core part of
https://github.com/denoland/deno/pull/27203 to make it easier to review
and land in parts.
It contains:
- The JS plugin code the deserializes and walks the buffer
- The Rust portion to serialize SWC to the buffer format (a bunch of
nodes are still todos, but imo these can land anytime later)
- Basic lint plugin types, without the AST node types to make this PR
easier to review
- Added more code comments to explain the format etc.
More fixes and changes will be done in follow-up PRs.
---------
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Implements a QUIC interface, loosely based on the WebTransport API (a
future change could add the WebTransport API, built on top of this one).
[quinn](https://docs.rs/quinn/latest/quinn/) is used for the underlying
QUIC implementation, for a few reasons:
- A cloneable "handle" api which fits quite nicely into deno resources.
- Good collaboration with the rust ecosystem, especially rustls.
- I like it.
<!--
Before submitting a PR, please read https://deno.com/manual/contributing
1. Give the PR a descriptive title.
Examples of good title:
- fix(std/http): Fix race condition in server
- docs(console): Update docstrings
- feat(doc): Handle nested reexports
Examples of bad title:
- fix#7123
- update docs
- fix bugs
2. Ensure there is a related issue and it is referenced in the PR text.
3. Ensure there are tests that cover the changes.
4. Ensure `cargo test` passes.
5. Ensure `./tools/format.js` passes without changing files.
6. Ensure `./tools/lint.js` passes.
7. Open as a draft PR if your work is still in progress. The CI won't
run
all steps, but you can add '[ci]' to a commit message to force it to.
8. If you would like to run the benchmarks on the CI, add the 'ci-bench'
label.
-->
This change fixes the premature exit of worker threads when there are still
remaining pending ops.
This change reuses the idea of #22647 (unref'ing `op_worker_recv_message` in
worker threads if closeOnIdle specified) and uses
`web_worker.has_message_event_listener` check in the opposite way as
#22944. (Now we continue the worker when `has_message_event_listener` is
true instead of stopping it when `has_message_event_listener` is false.
closes#23061closes#26154
This PR removes the public Deno.tracing.Span API.
We are not confident we can ship an API that is
better than the `@opentelemetry/api` API, because
V8 CPED does not support us using `using` to
manage span context. If this changes, we can
revisit this decision. For now, users wanting
custom spans can instrument their code using
the `@opentelemetry/api` API and `@deno/otel`.
This PR also speeds up the OTEL trace generation
by a 30% by using Uint8Array instead of
strings for the trace ID and span ID.
This commit adds `Deno.jupyter.image` API to display PNG and JPG images:
```
const data = Deno.readFileSync("./my-image.jpg");
Deno.jupyter.image(data);
Deno.jupyter.image("./my-image.jpg");
```
This PR adds a new `--unstable-node-globals` flag to expose Node globals
by default.
Fixes https://github.com/denoland/deno/issues/26611
---------
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>