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

Getting async leaking error when testing opine v2 #38

Closed
twilson63 opened this issue Dec 9, 2021 · 3 comments · Fixed by #39
Closed

Getting async leaking error when testing opine v2 #38

twilson63 opened this issue Dec 9, 2021 · 3 comments · Fixed by #39
Labels
bug Something isn't working needs investigation

Comments

@twilson63
Copy link

Issue: Getting async leaking error when testing opine v2

Setup:

  • Deno Version: 1.16.4
  • v8 Version: 9.7.16.15
  • Typescript Version: 4.4.2
  • SuperDeno Version: 4.7.1

Details

When running a simple test with opine@2.0.0 Deno Test Assertions return AssertionError: Test case is leaking async ops. - there are no async's in the example code which is pasted below.

server.ts

import { opine } from 'https://deno.land/x/opine@2.0.0/mod.ts'


export function build() {

 const app = opine();

  app.get('/', function (req, res) {
    res.send('Hello World')
  })

  return app
}

test.ts

import {superdeno} from 'https://deno.land/x/superdeno@4.7.1/mod.ts'
import { build } from './server.ts'
const app = build()

Deno.test('hello world', () => {
  superdeno(app)
    .get('/')
    .expect(200)
})

Run

deno test -A --unstable test.ts

Output

running 1 test from file:///workspace/deno-playground/test.ts
test hello world ... FAILED (12ms)

failures:

hello world
AssertionError: Test case is leaking async ops.
Before:
  - dispatched: 0
  - completed: 0
After:
  - dispatched: 2
  - completed: 1
Ops:
  op_net_accept:
    Before:
      - dispatched: 0
      - completed: 0
    After:
      - dispatched: 1
      - completed: 0

Make sure to await all promises returned from Deno APIs before
finishing test case.
    at assert (deno:runtime/js/06_util.js:41:13)
    at asyncOpSanitizer (deno:runtime/js/40_testing.js:128:7)
    at async resourceSanitizer (deno:runtime/js/40_testing.js:144:7)
    at async Object.exitSanitizer [as fn] (deno:runtime/js/40_testing.js:176:9)
    at async runTest (deno:runtime/js/40_testing.js:381:7)
    at async Object.runTests (deno:runtime/js/40_testing.js:494:22)

failures:

        hello world

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out (147ms)

error: Test failed
@asos-craigmorten
Copy link
Collaborator

asos-craigmorten commented Dec 10, 2021

Hey @twilson63 👋

The constructed superdeno chain is a promise. Can you try...

import {superdeno} from 'https://deno.land/x/superdeno@4.7.1/mod.ts';
import { build } from './server.ts';
const app = build();

Deno.test('hello world', async () => {
  await superdeno(app)
    .get('/')
    .expect(200);
});

And see if that resolves the issue?

@twilson63
Copy link
Author

Hey @asos-craigmorten,

Adding await, creates some strange results, randomly it seems to either pass or fail with the leaking async issue.

@asos-craigmorten asos-craigmorten added bug Something isn't working needs investigation labels Dec 10, 2021
cmorten added a commit that referenced this issue Jan 1, 2022
@cmorten
Copy link
Owner

cmorten commented Jan 1, 2022

Hey @twilson63, have released https://deno.land/x/superdeno@4.7.2 - let me know if you're still experiencing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs investigation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants