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

With await esbuild.stop(), deno test still detect resource leaks #3896

Open
loynoir opened this issue Aug 27, 2024 · 1 comment
Open

With await esbuild.stop(), deno test still detect resource leaks #3896

loynoir opened this issue Aug 27, 2024 · 1 comment

Comments

@loynoir
Copy link

loynoir commented Aug 27, 2024

bug

With await esbuild.stop(), deno test still detect resource leaks

reproduce

/tmp/reproduce/x.ts

import * as esbuild from 'npm:[email protected]'

const __filename = '/tmp/reproduce/x.ts'

Deno.test('a', async () => {
  const result = await esbuild.transform('const test: boolean = true', { loader: 'ts' })
  let _ = result

  await esbuild.stop()
})

Deno.test('b', async () => {
  const result = await esbuild.build({
    write: false,
    platform: 'node',
    format: 'esm',
    bundle: true,
    entryPoints: [__filename],
    plugins: [
      {
        name: 'hello-world-plugin',
        setup(build) {
          build.onResolve({ filter: /.*/ }, (args) => {
            if (args.path === __filename) {
              return null
            }

            return { external: true }
          })
        }
      }
    ]
  })
  let _ = result

  await esbuild.stop()
})

actual

$ deno test -A --filter a ./x.ts 
running 1 test from ./x.ts
a ... ok (12ms)

ok | 1 passed | 0 failed | 1 filtered out (13ms)
$ deno test -A --filter b ./x.ts 
running 1 test from ./x.ts
b ... ok (14ms)

ok | 1 passed | 0 failed | 1 filtered out (15ms)
$ deno test -A ./x.ts 
running 2 tests from ./x.ts
a ... ok (11ms)
b ... FAILED (6ms)

 ERRORS 

b => ./x.ts:12:6
error: Leaks detected:
  - A child process was started during the test, but not closed during the test. Close the child process by calling `proc.kill()` or `proc.close()`.
  - An async operation to wait for a subprocess to exit was started in this test, but never completed. This is often caused by not awaiting the result of a `Deno.Process#status` call.
To get more details where leaks occurred, run again with the --trace-leaks flag.

 FAILURES 

b => ./x.ts:12:6

FAILED | 1 passed | 1 failed (19ms)

error: Test failed

expected

With await esbuild.stop(), deno test not detect resource leaks.

env

deno 1.46.0

@evanw
Copy link
Owner

evanw commented Sep 22, 2024

I'm not sure what's up with Deno here but you're trying to use esbuild's npm library with Deno, not esbuild's Deno library with Deno. I suggest using esbuild's Deno library instead of esbuild's npm library as it's meant for use with Deno:

-import * as esbuild from 'npm:[email protected]'
+import * as esbuild from 'https://deno.land/x/[email protected]/mod.js'

I don't consider behavior of esbuild's npm library that doesn't work well with Deno's npm compatibility layer to be a problem with esbuild as esbuild's npm library is meant for npm, not for Deno.

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

No branches or pull requests

2 participants