Commit graph

1969 commits

Author SHA1 Message Date
Kamil Ogórek 1d7203c24c
fix(ext/flash): Correctly handle errors for chunked responses (#17303)
The leading cause of the problem was that `handleResponse` has
`tryRespondChunked` passed as an argument, which in turn is implemented
as a call to `core.ops.op_try_flash_respond_chuncked`, that throws in
the repro code.

`handleResponse` was not handled correctly, as it not returned any
value, and had no `catch` attached to it.
It also effectively was never correctly handled inside two other blocks
with `resp.then` and `PromisePrototypeCatch(PromisePrototypeThen(resp,
"..."))` as well, as it just short-circuited the promise with an empty
resolve, instead of relying on the last `(async () => {})` block.

This change makes `handleResponse` return a correct value and attach
`onError` handler to the "non-thenable" variant of response handling
code.
2023-01-14 15:06:28 +01:00
Divy Srivastava ae2981d7ac
fix(runtime/fs): preserve permissions in copyFileSync for macOS (#17412)
Fixes https://github.com/denoland/deno/issues/16921
2023-01-14 13:45:30 +00:00
Kiryl Dziamura 934ed8e7d1
fix(npm): use original node regex in npm resolution (#17404)
Fixes regex for matching conditional exports in a package.
Updated to the same regex Node.js uses.
2023-01-14 00:57:24 +01:00
Bartek Iwańczuk 1b17985c5a
fix(permissions): lock stdio streams when prompt is shown (#17392)
This commit changes permission prompt to lock stdio streams when prompt
is shown.
2023-01-13 10:05:07 -05:00
Bartek Iwańczuk 9644220df2
tests: Disable flaky flash_shutdown test (#17390) 2023-01-13 15:19:20 +01:00
Yiyu Lin a00e432297
chore: add copyright_checker tool and add the missing copyright (#17285) 2023-01-13 16:51:32 +09:00
Bartek Iwańczuk 9e282155b7
tests: move integration tests to a single module (#17380)
Effectively reverts changes done in
https://github.com/denoland/deno/pull/16816
2023-01-13 02:59:13 +01:00
Bartek Iwańczuk 4d66be1e05
Revert "test: fix flaky deno_land_unsafe_ssl test (#17357)" (#17368)
This reverts commit ee2c6cb04a.

Closes https://github.com/denoland/deno/issues/17359
2023-01-12 15:25:20 +01:00
Leo Kettmeir cc806cdf21
fix: check if BroadcastChannel is open before sending (#17366)
Fixes #16978
2023-01-12 13:43:36 +01:00
Leo Kettmeir a6b3910bdf
feat: allow passing a ReadableStream to Deno.writeFile/Deno.writeTextFile (#17329)
Closes #13229
2023-01-12 03:37:23 +01:00
Bartek Iwańczuk ee2c6cb04a
test: fix flaky deno_land_unsafe_ssl test (#17357) 2023-01-12 01:04:25 +01:00
Leo Kettmeir b0e0e4f24b
fix: don't panic on resolveDns if unsupported record type is specified (#17336)
Fixes #14373
2023-01-11 21:31:14 +01:00
Nayeem Rahman 71ea4ef274
fix(watch): preserve ProcState::file_fetcher between restarts (#15466)
This commit changes "ProcState" to store "file_fetcher" field in an "Arc",
allowing it to be preserved between restarts and thus keeping the state
alive between the restarts. File watchers for "deno test" and "deno bench"
now reset "ProcState" between restarts.
2023-01-10 16:28:10 +01:00
Bartek Iwańczuk 636352e0ca
fix(npm): allow to read package.json if permissions are granted (#17209)
This commit changes signature of "deno_core::ModuleLoader::resolve" to pass
an enum indicating whether or not we're resolving a specifier for dynamic import.

Additionally "CliModuleLoader" was changes to store both "parent permissions" (or
"root permissions") as well as "dynamic permissions" that allow to check for permissions
in top-level module load an dynamic imports.

Then all code paths that have anything to do with Node/npm compat are now checking
for permissions which are passed from module loader instance associated with given
worker.
2023-01-10 14:35:44 +01:00
Leo Kettmeir e6c49d14b1
feat(runtime/os): add Deno.env.has() (#17315) 2023-01-09 20:19:55 +01:00
David Sherret 2be1282be4
fix(install): should always include --no-config in shim unless --config is specified (#17300)
Closes #17294
2023-01-08 09:03:55 -05:00
Bartek Iwańczuk fac6447815
refactor(permissions): add PermissionsContainer struct for internal mutability (#17134)
Turns out we were cloning permissions which after prompting were discarded,
so the state of permissions was never preserved. To handle that we need to store
all permissions behind "Arc<Mutex<>>" (because there are situations where we
need to send them to other thread).

Testing and benching code still uses "Permissions" in most places - it's undesirable
to share the same permission set between various test/bench files - otherwise
granting or revoking permissions in one file would influence behavior of other test
files.
2023-01-07 17:25:34 +01:00
David Sherret d1cdf65b10
fix(npm): handle declaration file resolution where packages incorrectly define "types" last in "exports" (#17290)
Closes #17279
2023-01-06 12:57:52 -05:00
David Sherret 0ee64ad847
fix: upgrade deno_ast to 0.23 (#17269)
Closes #17172
Closes #15669
Closes #8529
2023-01-04 18:54:54 -05:00
Asher Gomez 1b001d1b18
fix(permissions): process URL in Deno.FfiPermissionDescriptor.path for revoke() and request() (#17094)
Previously, `Deno.permissions.[revoke|request]()` wouldn't correctly
process the `path: URL` when `name` was `ffi`. This change fixes that
behaviour and adds a new function, `formDescriptor()`, to ensure `URL`
arguments are consistently handled across
`Deno.permissions.[query|revoke|request]()`.
2023-01-03 21:50:14 +01:00
Fenix 501472f06b
fix(cli): bundle command support shebang file (#17113) 2023-01-03 16:19:28 +00:00
David Sherret 10e4b2e140
chore: update copyright year to 2023 (#17247)
Yearly tradition of creating extra noise in git.
2023-01-02 21:00:42 +00:00
Bartek Iwańczuk 98bbf87742
fix(lsp): less agressive completion triggers (#17225)
Closes https://github.com/denoland/deno/issues/17056
Closes https://github.com/denoland/deno/issues/17055
2022-12-30 14:11:50 +01:00
Bartek Iwańczuk 218d7ab778
fix(lsp): completions for private variables (#17220) 2022-12-29 22:22:47 +01:00
Bartek Iwańczuk ef5f8cd265
fix(lsp): "Add all missing imports" uses correct specifiers (#17216)
This commit fixes "Add all missing imports" quick fix; before
it was replacing all occurrences with the same specifier. Now
every line returned from TSC is processed individually.
2022-12-29 21:07:09 +01:00
Bartek Iwańczuk bece1ce057
feat(unstable): Add Deno.Conn.ref()/unref() (#17170)
This commit adds "Deno.Conn.ref()" and "Deno.Conn.unref()" methods.

These methods can be used to make connection block or not block the
event loop from finishing. Refing/unrefing only influences "read" 
operations - ie. scheduling writes to a connection _do_ keep event 
loop alive.

Required for https://github.com/denoland/deno/issues/16710
2022-12-28 10:29:48 +01:00
Kamil Ogórek 7ce2b58bcf
feat(unstable): Add "Deno.osUptime()" API (#17179)
This PR adds support for `Deno.osUptime` which reports number of seconds
since os was booted. It will allow us to be compatible with Node's `os.uptime` -
https://nodejs.org/api/os.html#osuptime

Partially based on
https://docs.rs/uptime_lib/latest/src/uptime_lib/lib.rs.html
2022-12-27 00:16:12 +01:00
Bartek Iwańczuk 208c91b68f
fix(core): run macrotasks and next ticks after polling dynamic imports (#17173)
This commit fixes handling of rejected promises in dynamic imports
evaluation.

Previously we were running callbacks for next ticks and macrotasks
_before_ polling
dynamic imports and checked for unhandled rejections immediately after.
This is wrong,
as `unhandledrejection` event is dispatched and its callbacks are run as
macrotasks.

This commit changes order of actions performed by the event loop to
following:
- poll async ops
- poll dynamic imports
- run next tick callbacks
- run macrotask callbacks
- check for unhandled promise rejections
2022-12-23 19:46:24 +01:00
Kamil Ogórek 2a61b5fdd4
fix(ext/fetch): Guard against invalid URL before its used by reqwest (#17164) 2022-12-23 17:39:14 +01:00
Kamil Ogórek 6a47ffa4d3
fix(core): Do not print errors prop for non-AggregateError errors (#17123)
This commit fixes formatting of JSError with "errors" property. Before this
commit all instances of "Error" were treated as if they were "AggregateError"
if they had "errors" property. After this commit only actual instances of 
"AggregateError" are formatted in such a way, while instances of "Error"
that have "errors" property are formatted without showing details of "errors".
2022-12-21 01:18:49 +01:00
David Sherret 423474caa8
fix(lsp/format): language formatter used should be based on language id (#17148)
Closes #11897
2022-12-20 15:19:35 -05:00
David Sherret 8165cded14
fix: ignore local lockfile for deno install and uninstall (#17145)
Closes #17116
2022-12-20 12:00:57 -05:00
Luca Casonato 8e947bb674
fix(ext/http): close stream on resp body error (#17126)
Previously, errored streaming response bodies did not cause the HTTP
stream to be aborted. It instead caused the stream to be closed gracefully,
which had the result that the client could not detect the difference
between a successful response and an errored response.

This commit fixes the issue by aborting the stream on error.
2022-12-20 08:46:45 +00:00
Kamil Ogórek 199144daf0
fix(cli): allow for specifying noErrorTruncation compiler option (#17127)
Fixes https://github.com/denoland/deno/issues/16568
2022-12-19 20:29:44 -05:00
Leo Kettmeir 80955dfa61
fix: display URL in invalid URL error (#17128) 2022-12-19 20:58:02 +01:00
Kamil Ogórek 118a35f3bc
fix(cli): do not clear screen for non-TTY environments in watch mode (#17129) 2022-12-19 12:59:32 -05:00
Bartek Iwańczuk 383d40a33b
fix(npm): conditional exports with --node-modules-dir (#17111)
This commit fixes conditional exports in `require()` implementation
if `--node-modules-dir` flag is used.
2022-12-19 17:09:54 +01:00
Luca Casonato d1f6b51990
test(ext/fetch): fix test in release mode (#17125) 2022-12-19 15:18:14 +01:00
Luca Casonato 43b6390629
fix(ext/fetch): handle errors in req body stream (#17081)
Right now an error in a request body stream causes an uncatchable
global promise rejection. This PR fixes this to instead propagate the
error correctly into the promise returned from `fetch`.

It additionally fixes errored readable stream bodies being treated as
successfully completed bodies by Rust.
2022-12-19 12:49:00 +01:00
David Sherret e9ecfdd20a
fix(runtime): Deno.memoryUsage().rss should return correct value (#17088)
This commit changes implementation of "Deno.memoryUsage()" to return
correct value for "rss" field. To do that we implement a specialized function
per os to retrieve this information.
2022-12-17 23:25:51 +01:00
linbingquan f46df3e359
chore: update to Rust 1.66.0 (#17078) 2022-12-17 23:20:15 +01:00
David Sherret f2c9cc500c
fix(lint): column number for pretty reporting was off by 1 (#17107)
Closes #17086
2022-12-17 16:00:33 -05:00
Bartek Iwańczuk ff71ef8175
fix(repl): errors shouldn't terminate repl (#17082)
This commit changes REPL to never surface errors coming
from code execution, but instead print them as errors
to the REPL itself.
2022-12-16 17:11:10 +01:00
David Sherret 9e977cd6aa
fix(npm): improve exports resolution when type checking (#17071)
Closes #17012
2022-12-15 21:15:25 -05:00
Leo Kettmeir 50c7526526
fix: re-add Response.json static method (#17061)
Same as #16040
2022-12-15 10:33:19 -05:00
David Sherret 9e9e8f1e38
fix: upgrade to TS 4.9.4 (#17048) 2022-12-14 13:00:51 -05:00
Bartek Iwańczuk 435948e470
feat(repl): support npm packages (#16770)
Co-authored-by: David Sherret <dsherret@gmail.com>
2022-12-13 13:53:32 +01:00
Leo Kettmeir 5d9bb8b4b0
feat: support createNew in Deno.writeFile (#17023) 2022-12-13 05:12:49 +01:00
Leo Kettmeir a2ba573e77
fix: default to "inherit" for Deno.Command#spawn()'s stdout & stderr (#17025) 2022-12-13 05:12:19 +01:00
Bartek Iwańczuk 4a17c93088
feat: add --inspect-wait flag (#17001)
This commit adds new "--inspect-wait" flag which works similarly
to "--inspect-brk" in that it waits for inspector session to be
established before running code. However it doesn't break on the first
statement of user code, but instead runs it as soon as a session
is established.
2022-12-12 15:33:30 +01:00