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

chore: upgrade to esbuild 0.20.0 #2293

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

chore: upgrade to esbuild 0.20.0 #2293

wants to merge 2 commits into from

Conversation

deer
Copy link
Contributor

@deer deer commented Jan 31, 2024

Sadly this isn't working due to failures like this:

deno test -A src/build/esbuild_test.ts
running 1 test from ./src/build/esbuild_test.ts
esbuild ...
  esbuild snapshot with cwd=Deno.cwd() ...
ok | 0 passed | 0 failed (88ms)

error: Promise resolution is still pending but the event loop has already resolved.

I'm not sure what I'm doing wrong, but I thought I would open this as a draft PR so others can see what I've started.
Note the esbuild_deno_loader import is coming from lucacasonato/esbuild_deno_loader#108.

@deer
Copy link
Contributor Author

deer commented Feb 6, 2024

The error is reproducible with the following minimal case:

import * as esbuild from "https://deno.land/x/esbuild@v0.20.0/mod.js";

Deno.test("esbuild", async (t) => {
  await t.step("esbuild snapshot with cwd=Deno.cwd()", async () => {
    const builder = new EsbuildBuilder();
    await builder.build();
  });
});

export class EsbuildBuilder {
  async build(): Promise<boolean> {
    await esbuild.initialize({});

    try {
      await esbuild.build({ entryPoints: ["./someFile.ts"] });
      return true;
    } finally {
      await esbuild.stop();
    }
  }
}

I'll work on continuing to debug later.

@deer
Copy link
Contributor Author

deer commented Feb 6, 2024

After taking a break I decided to put this into the esbuild source and modify some things so I could log more. The test is basically the same as before, except now I import like this: import * as esbuild from "../deno/mod.js";

I modified the existing:

    close: async () => {
      await writer.close();
      await reader.cancel();
      await child.status;
    },

to have some extra logging and to invoke child.kill, just for good measure:

    close: async () => {
      try {
        console.log(`resources before writer.close(): ${JSON.stringify(Deno.resources())}`);
        await writer.close();
        console.log(`resources before reader.cancel(): ${JSON.stringify(Deno.resources())}`);
        await reader.cancel();
        console.log(`resources before child.kill(): ${JSON.stringify(Deno.resources())}`);
        child.kill();
        console.log(`resources before child.status: ${JSON.stringify(Deno.resources())}`);
        await child.status;
        console.log("does this log");
      } catch (e) {
        console.log("are there any errors");
        console.log(JSON.stringify(Deno.resources()));
        console.log(e);
      }
    },

and then I got the following:

esbuild ...
  esbuild snapshot with cwd=Deno.cwd() ...
------- output -------
let a = 2 + 2;
resources before writer.close(): {"0":"stdin","1":"stdout","2":"stderr","3":"childStdin","4":"childStdout","5":"child"}
resources before reader.cancel(): {"0":"stdin","1":"stdout","2":"stderr","4":"childStdout","5":"child"}
resources before child.kill(): {"0":"stdin","1":"stdout","2":"stderr","5":"child"}
resources before child.status: {"0":"stdin","1":"stdout","2":"stderr","5":"child"}

ok | 0 passed | 0 failed (94ms)

error: Promise resolution is still pending but the event loop has already resolved.

So it seems like something in the call to await child.status is causing the event loop to exit and not return properly, sinice we don't see does this log in the logs.

@lucacasonato @marvinhagemeister, I'll pass this over to you guys at this point, since I'm not very good at debugging the deno runtime itself.

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

Successfully merging this pull request may close these issues.

None yet

1 participant