Closes#30570
Changes in this PR:
- Implement `ino`, `nlink`, and `blocks` properties of `Deno.FileInfo`
on Windows. These changes are automatically reflected to the
corresponding node stat function. In order to do so, I had to tinker
with the
[createByteStruct](a3a904da14/ext/fs/30_fs.js (L297))
function to create another optional int type, apart from `?u64`. It's
common for small sized files on Windows (particularly NTFS file system)
to have a `Stats.blocks` property of 0, and currently all 0 values with
type `?u64` will be coerced into `null` by `createByteStruct`.
- Refactor the `BigIntStats` and `Stats` class, to use the same class
with Node.js that are provided from
[utils.mjs](7f8e488c36/ext/node/polyfills/internal/fs/utils.mjs (L577)).
Also ensures that all properties are not `null` or `undefined`.
- Addresses the `prefer-primordials` lint rule.
This commit adds support for specifying a `Deno.HttpClient` in the
`client` field of the `WebSocketOptions` bag. This mirrors how users
pass a custom HTTP client to `fetch`.
Additionally the underlying connection for websockets are now
established through the same mechanism used for `fetch`, which
means that `WebSocket` now correctly uses HTTP proxies, like
when configuring the `HTTP_PROXY` env var.
---------
Signed-off-by: Luca Casonato <hello@lcas.dev>
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 commit adds `SubprocessReadableStream` interface that are used
for `ChildProcess.stdout` and `ChildProcess.stderr`. It's an extension
to a regular `ReadableStream` that provides convenience methods to collect
the output and parse it with `.bytes()`, `.arrayBuffer()`, `.text()` and
`.json()` helper methods (similarly to the ones available on `Response`).
Closes https://github.com/denoland/deno/issues/30323
---------
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
This changes the second argument in the WebSocket constructor to be able
to take an object, which can contain a headers field with which the
headers for the connection can be set.
---------
Co-authored-by: Luca Casonato <hello@lcas.dev>
This commit adds `tcpBacklog` argument to `Deno.listen`,
`Deno.listenTls` and `Deno.serve` APIs.
The argument specifies maximum number of pending connections in the
listen queue, and by default is set to 511.
Users that expect huge bursts of traffic can customize this
option to a higher value.
Ref https://github.com/denoland/deno/pull/30471
Closes https://github.com/denoland/deno/issues/30388
Fixes https://github.com/denoland/deno/issues/28903
Closes https://github.com/denoland/deno/issues/26190
- Adds a new option `unsafelyDisableHostnameVerification` to
`Deno.connectTls` and `Deno.startTls` to ignore DNS name mismatch errors
from rustls server verifier.
- Disable hostname verification in Node.js TLSSocket if
`checkServerIdentity` is a no-op.
---------
Signed-off-by: Divy Srivastava <dj.srivastava23@gmail.com>
This PR updates the type definitions for `setTimeout` and `setInterval`
in `lib.deno.shared_globals.d.ts` to accept both a string and a function
as the callback, matching the DOM standard and Deno's runtime behavior.
Previously, the types only allowed a function, but Deno's implementation
(and the web standard) also allow a string, which is evaluated as code.
This change ensures that TypeScript users can use both forms without
type errors, aligning Deno's types with web compatibility.
Fixes#30166
This commit changes `Deno.execPath()` API to no longer require
read permission.
This change is dictated by the fact that in common scenarios, requiring
read permission is less secure than not requiring permissions - if
a user wants to spawn a Deno subprocess using the current executable,
they would do something like:
```
new Deno.Command(Deno.execPath(), { args: ["eval", "1+1"] }).outputSync();
```
To run this program, currently one needs to pass `--allow-read
--allow-run=deno` flags.
It's possible to limit scope of `--allow-read` flag, but it's really
cumbersome to do,
so most users will opt to give a blanket `--allow-read` permission.
Not requiring read permissions allows the above program to be run with
just `--allow-run=deno` flag.
This change is in similar to relaxing of permissions in `Deno.cwd()` API
done in https://github.com/denoland/deno/pull/27192.
Ref
https://github.com/denoland/deno/issues/20061#issuecomment-2942497783
This commit adds support for using
[vsock](https://man7.org/linux/man-pages/man7/vsock.7.html) transport in
fetch API on Linux and macOS.
Similar to #29154, a vsock transport can be specified in the `proxy`
field when calling `Deno.createHttpClient`.
```ts
const client = Deno.createHttpClient({
proxy: {
transport: "vsock",
cid: 2,
port: 80,
},
});
await fetch("http://localhost/ping", { client });
```
This commit adds support for using Unix socket proxies in `fetch` API.
This is facilitated by passing an appropriate `Deno.HttpClient` instance
to the `fetch` API:
```
const client = Deno.createHttpClient({
proxy: {
transport: "unix",
path: "/path/to/unix.sock",
},
});
await fetch("http://localhost/ping", { client });
```
Closes https://github.com/denoland/deno/issues/8821
---------
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
This PR adds support for comments in the AST for lint plugins.
- The `Program` node has a `comments` field pointing to an array of all
comments.
- `SourceCode.getAllComments()`: Returns all comments (same as
`program.comments`)
- `SourceCode.getCommentsBefore(node)`: Get all comments before this
Node
- `SourceCode.getCommentsAfter(node)`: Get all comments after this Node
- `SourceCode.getCommentsInside(node)`: Get all comments inside this
Node
ESLint docs:
-
https://eslint.org/docs/latest/extend/custom-rules#accessing-the-source-code
- https://eslint.org/docs/latest/extend/custom-rules#accessing-comments
`Deno.env.get` returns undefined when the environment variable is not
present. I initially interpreted this doc string to indicate that it
would return the string literal `"undefined"`, which isn't right.
Could use backticks here as above, but a little confusing in a JS
context where this also indicates a (template) string literal.
This is technically **BREAKING** as it removes a public API, but the
brand is type-only and the chance of anyone actually relying on this
seems very unlikely.
---------
Co-authored-by: David Sherret <dsherret@gmail.com>
Ref #26819
An optional **timeout** parameter has been added to the
**Deno.connect()** interface. This parameter allows specifying a timeout
(in milliseconds) within which the application must establish a
connection. If the timeout is exceeded without successfully connecting,
the operation is automatically aborted with an error. If the parameter
is not provided, the default behavior remains unchanged (no timeout).
Currently, the timeout functionality is implemented only for TCP
connections. Other connection types are not affected by this change.
---------
Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
Noticed that the `.parent` type was missing for AST nodes for our JS
lint API. Whenever possible I've only specified the limited
possibilities of parent types, but when it's too complex I defaulted to
just `Node`.