Coder Social home page Coder Social logo

Comments (6)

antoniogamiz avatar antoniogamiz commented on June 14, 2024 1

I know it's quite weird... At first, I thought it was due to some error in my files, but I have cleaned the cache and updated Deno to 1.4.6 and it's still happening.

I have downloaded this repo and I have run the tests but they are ok so...

I will try to investigate what's being left hanging.

from superoak.

antoniogamiz avatar antoniogamiz commented on June 14, 2024 1

Sorry ignore those two replies, what you have said works great. Thanks!

from superoak.

asos-craigmorten avatar asos-craigmorten commented on June 14, 2024

Hey @antoniogamiz thanks for raising - not ideal at all given that really is the simplest usecase! 😅

Will try to spare some time soon to investigate - if you have time and are keen, please do have a dive into the code to figure out what async/promising thing is being left hanging.

It's odd this hasn't been picked up in the tests but haven't touched this in a month and may be that something in Oak / Deno has moved along since September... or just have been super lucky (or unlucky depending on how see it) with an async op race condition.

from superoak.

asos-craigmorten avatar asos-craigmorten commented on June 14, 2024

Haven't dug too deeply, but from a quick reminder of the code, performing:

const request = await superdeno(app);

Will launch an Oak server and resolve with a promise which we are awaiting. Given nothing then stops said Oak sever, my guesses are that it (the server) is effectively the async op that is not cleaned up (or more accurately the async iterator inside the Oak server that processes requests hasn't been escaped).

Hence I'm curious if the issue goes away if you actually complete the usage of superdeno as documented and make an action / assertion - superdeno has it's own internal logic to close the Oak server using an AbortController, and this will only be fired when the underlying superdeno .end() method is called, either implicitly or explicitly (REF: https://github.com/asos-craigmorten/superdeno/blob/main/src/test.ts#L350)

For instance, updating to the following solves it for me:

import { Application} from "https://deno.land/x/[email protected]/mod.ts";
import { superoak } from "https://deno.land/x/[email protected]/mod.ts";

const app = new Application();
app.use((ctx: any) => {
  ctx.response.body = "Hello world!";
});

Deno.test("Example", async () => {
  const request = await superoak(app);

  await request.get("/"); // Need to invoke at least one superdeno method otherwise the underlying server is left runner forever (well... until it gets cleaned up by Deno which will tell you off).
});

from superoak.

antoniogamiz avatar antoniogamiz commented on June 14, 2024

And why does this fail, then? It produces the same error:

import { Application } from "https://deno.land/x/[email protected]/mod.ts";
import { superoak } from "https://deno.land/x/[email protected]/mod.ts";

const app = new Application();
app.use((ctx: any) => {
  ctx.response.body = "Hello world!";
});

Deno.test("Example", async () => {
  const request = await superoak(app);

  await request.get("/").expect({});
});

from superoak.

antoniogamiz avatar antoniogamiz commented on June 14, 2024

I'm passing an object because my endpoint returns a JSON, so I want to test that.

from superoak.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.