-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
esbuild inside Deno.test() leaks resources #3682
Comments
It looks like this isn't caught by esbuild's current tests because esbuild's tests do something like this, which for some reason doesn't cause a problem with Deno: import { assertEquals } from 'https://deno.land/std@0.218.0/assert/mod.ts'
import * as esbuild from 'https://deno.land/x/esbuild@v0.20.1/mod.js'
const withTimeout = async (fn) => new Promise((resolve, reject) => {
const minutes = 5
const timeout = setTimeout(() => reject(new Error(`Timeout for "${name}" after ${minutes} minutes`)), minutes * 60 * 1000)
const cancel = () => clearTimeout(timeout)
const promise = fn()
promise.then(cancel, cancel)
promise.then(resolve, reject)
})
Deno.test('should transform', () => withTimeout(async () => {
const result = await esbuild.transform('const test: boolean = true', { loader: 'ts' })
assertEquals(result.code, 'const test = true;\n')
await esbuild.stop()
}))
Deno.test('should transform again', () => withTimeout(async () => {
const result = await esbuild.transform('const test: boolean = true', { loader: 'ts' })
assertEquals(result.code, 'const test = true;\n')
await esbuild.stop()
})) I think the problem is perhaps that esbuild's API calls Deno's I can remove the call to |
@evanw Sorry for not responding earlier. I just analyzed what the issue is, and I do not think Deno is doing anything wrong here. The problem is that You can actually also trivially see this issue by writing some code top-level: import * as esbuild from "https://deno.land/x/esbuild@v0.20.0/mod.js";
const res = await esbuild.build({
entryPoints: ["./demo.ts"],
write: false,
format: "esm",
platform: "neutral",
});
console.log(res.outputFiles[0].text);
await esbuild.stop(); This will fail with:
If you were to implement a The fix is simple, and works just like the reference-counted |
When using esbuild inside a
Deno.test()
esbuild leaks at least one pending resource which Deno reports as a test error. Calling esbuild'sawait stop()
does not work.Deno version: 1.41.1 (latest)
esbuild version: 0.21.1 (latest)
A minimal reproducible example is this test which I expect to pass:
Will output:
The same problem applies to the npm: version, albeit intermittently:
Will output 90% of the time:
The text was updated successfully, but these errors were encountered: