Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deno: Usage of deprecated API with >= Deno 1.40 #3609

Closed
marvinhagemeister opened this issue Jan 25, 2024 · 7 comments · Fixed by #3611
Closed

Deno: Usage of deprecated API with >= Deno 1.40 #3609

marvinhagemeister opened this issue Jan 25, 2024 · 7 comments · Fixed by #3611

Comments

@marvinhagemeister
Copy link

With the recent Deno 1.40 release some older APIs were marked as deprecated. Some of those are used within the deno esbuild adapter and print warning messages to the terminal.

Stack trace:
  at https://deno.land/x/[email protected]/mod.js:1888:45
  at eventLoopTick (ext:core/01_core.js:59:7)
  at async file:///Users/marvinh/dev/test/esbuild-deprecations/foo.ts:3:1

hint: Use `Deno.stderr` instance methods instead.
hint: It appears this API is used by a remote dependency. Try upgrading to the latest version of that dependency.

warning: Use of deprecated "Deno.isatty()" API. This API will be removed in Deno 2.

Stack trace:
  at https://deno.land/x/[email protected]/mod.js:1888:26
  at eventLoopTick (ext:core/01_core.js:59:7)
  at async file:///Users/marvinh/dev/test/esbuild-deprecations/foo.ts:3:1

hint: Use `Deno.stdin.isTerminal()`, `Deno.stdout.isTerminal()` or `Deno.stderr.isTerminal()` instead.
hint: It appears this API is used by a remote dependency. Try upgrading to the latest version of that dependency.

warning: Use of deprecated "Deno.run()" API. This API will be removed in Deno 2.

Stack trace:
  at https://deno.land/x/[email protected]/mod.js:1889:26
  at eventLoopTick (ext:core/01_core.js:59:7)
  at async file:///Users/marvinh/dev/test/esbuild-deprecations/foo.ts:3:1

hint: Use "Deno.Command()" API instead.
hint: It appears this API is used by a remote dependency. Try upgrading to the latest version of that dependency.

Steps to reproduce

  1. Upgrade Deno to 1.40.1 deno upgrade
  2. Create a file foo.ts with these contents:
import * as esbuild from "https://deno.land/x/[email protected]/mod.js";

await esbuild.build({
  entryPoints: ["foo"],
  bundle: true,
  plugins: [
    {
      name: "foo-entry",
      setup(build) {
        build.onResolve({ filter: /foo/ }, (args) => {
          return { path: args.path, namespace: "foo" };
        });

        build.onLoad({ filter: /.*/, namespace: "foo" }, () => {
          return { contents: "export default 42;", loader: "ts" };
        });
      },
    },
  ],
});

esbuild.stop();
  1. Run deno run -A foo.ts
@dbushell
Copy link

The warnings have gotten rather obnoxious now! I guess Deno 2 is getting closer?

I've added a PR to update to the new APIs

@evanw
Copy link
Owner

evanw commented Jan 26, 2024

I did some work on this: #3611. However, I'm blocked by some weird Deno behavior with the new APIs on Windows. I don't currently have access to Windows and also don't use Deno myself and am pretty unfamiliar with it. I could use some tips for how to terminate a Deno child process on Windows using the new APIs (or at least, how to get Deno's tests to not care that the test started a child process).

@evanw
Copy link
Owner

evanw commented Jan 26, 2024

I just realized that Deno now supports npm packages. So I believe a workaround for this is to import from npm:esbuild instead of https://deno.land/x/esbuild.

@dbushell
Copy link

yes both npm:esbuild and npm:esbuild-wasm work for my purposes in Deno 👍

I noticed at the end of a GitHub action (denoland/setup-deno@v1) I was seeing:

Warning: Not implemented: ChildProcess.prototype.disconnect

@marvinhagemeister
Copy link
Author

@evanw Right good point, I'll try to move to the npm package on Monday. If it works then it's something we should recommend deno users to switch to.

@evanw
Copy link
Owner

evanw commented Jan 27, 2024

I noticed at the end of a GitHub action (denoland/setup-deno@v1) I was seeing:

Warning: Not implemented: ChildProcess.prototype.disconnect

I'm getting that too. It looks like perhaps this just always happens right now whenever you call the node subprocess.kill() API. This causes Deno to unconditionally call a stub of a method called disconnect that prints this warning:

https://github.com/denoland/deno/blob/6109717c4a4d8139fdbf7165aac3bff2722e16d2/ext/node/polyfills/internal/child_process.ts#L306-L322

@dbushell
Copy link

dbushell commented Jan 27, 2024

Unfortunately npm:esbuild-wasm does not work on Deno Deploy:

PermissionDenied: Spawning subprocesses is not allowed on Deno Deploy.
    at Command.spawn (ext:deno_deploy/process.js:23:11)
    at new ChildProcess (ext:deno_node/internal/child_process.ts:121:10)
    at Object.spawn (node:child_process:105:10)
    at ensureServiceIsRunning (file:///node_modules/.deno/[email protected]/node_modules/esbuild-wasm/lib/main.js:1969:29)
    at Module.initialize (file:///node_modules/.deno/[email protected]/node_modules/esbuild-wasm/lib/main.js:1958:3)
    at esbuildStart 

The current Deno version from https://deno.land/x/[email protected]/wasm.js does work on Deploy.

I tried npm:esbuild but:

 Failed to resolve module "npm:@esbuild/[email protected]"

I don't think it'd work anyway even with the binary. If I remember Deno Deploy having no writeable file system was an issue.

@marvinhagemeister do you know if Fresh is running esbuild on Deploy?

edit: nevermind 0.20.0 is all good nice work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants