D
Deno

help

Leaking operation op_http_close in tests

SSteve12/4/2023
I tried to update my repositories from Deno 1.38.1 to 1.38.4. After the update my test keeps failing with the error message "1 async operation to op_http_close was started in this test, but never completed.". I tried every version in between but had to revert to 1.38.1. Failing CI run: https://github.com/sgohlke/deno-web/actions/runs/7092893428/job/19305155074 Revert to Deno 1.38.1 is green: https://github.com/sgohlke/deno-web/actions/runs/7092893428 Failing test: https://github.com/sgohlke/deno-web/blob/main/response/responseFunctions_test.ts#L34 I use AbortController to send an AbortSignal to the server. I tried to add the finished function and console.log like in the example on https://deno.land/api@v1.38.4?s=Deno.serve , it did not help. I also tried to store the server in a const and call "await server.shutdown()", but this results in TS error "TS2339 [ERROR]: Property 'shutdown' does not exist on type 'HttpServer'." Does anyone have an idea how to fix this issue?
GitHub
Use action workflow · sgohlke/deno-web@59a6c5c
Webserver and helper functions in Deno. Contribute to sgohlke/deno-web development by creating an account on GitHub.
GitHub
Use action workflow · sgohlke/deno-web@59a6c5c
Webserver and helper functions in Deno. Contribute to sgohlke/deno-web development by creating an account on GitHub.
Deno
Deno.serve | Runtime APIs | Deno
Serves HTTP requests with the given handler.
GitHub
deno-web/response/responseFunctions_test.ts at main · sgohlke/deno-...
Webserver and helper functions in Deno. Contribute to sgohlke/deno-web development by creating an account on GitHub.
DAHDeno AI Helper12/4/2023
I wasn't able to find the answer to your question in the official Deno documentation. However, based on the information you've provided in your message, I can offer some general advice that might help you address the issue. From what you've described, it seems like there might be an asynchronous operation related to op_http_close that is not being properly awaited or closed in your tests. This can happen if the server is still running or if there are pending requests that have not been handled when the test completes. Regarding the TS2339 error you're encountering when trying to call await server.shutdown(), it's possible that the HttpServer type does not have a shutdown method in the version of Deno you are using. This could be due to a change in the API or a discrepancy between the documentation and the actual implementation. Here are a few things you could check or try: 1. Ensure that you are properly closing the server after the test. This might involve calling a method to stop the server or ensuring that all connections are closed. 2. If you're using an AbortController to signal the server to stop, make sure that the signal is being handled correctly and that it actually leads to the server shutting down. 3. Double-check the Deno documentation for the version you are using to see if there have been any changes to the HttpServer API that might affect how the server should be shut down. Please note that this advice is not based on the Deno documentation, and I recommend double-checking the accuracy of the advice given. If you continue to experience issues, you might want to consider reaching out to the Deno community for further assistance or looking for recent changes in the Deno release notes that might explain the behavior you're observing.
LLeokuma12/5/2023
I think you can open an issue and paste your test code there. There have been some questions about the new sanitizers, and some of them were actually bugs
Bbartlomieju12/5/2023
CC @mmastrac
Mmmastrac12/5/2023
It looks like you need to get the return value from Deno.serve and await server.finished. The combination of fetch + serve requires this as there's a cached connection running in the background and we need to wait for it all to get torn down after the abort controller fires. You can also use the asyncDispose functionality via using, which IIRC is using _server = Deno.serve which should trigger and wait on shutdown when the block ends
SSteve12/6/2023
Thank you, the test is now green again. I also tried calling await server.finished before abortController.abort , as you stated first calling abort then finished fixed the problem. I'm not familiar with using yet, will try this out later.

Looking for more? Join the community!

Recommended Posts
Does BroadcastChannel preserve the message order if the receiver is in a different geo-location?Does BroadcastChannel preserve the message order if the receiver is in a different geo-location?NPM CCXT Not WorkingI'm trying to run the NPM Package CCXT and I'm getting an `"ERR_MODULE_NOT_FOUND"` error any help How do you use a private docker hub image on AWS Lightsail?I'm following the guide here https://docs.deno.com/runtime/manual/advanced/deploying_deno/aws_lightsIs there a way to reset/flush my deno vk queues on deploy?Nothing seems to be queuing. I would like to reset it if possible?Return lazy struct fields from OpMy goal is to build a plugin system which allows invoking user defined code. One of the features I aRelative path in WebSocketWhy does relative path in `WebSocket` not work?Relative path in `npm:` specifierI have this in my import map: ``` "@heroicons/react/": "npm:@heroicons/react@2.0.18/" ``` And I try Transitive dependencies with node_modulesHi all, today I stumbled upon this not-sure-if-a-bug: ```ts import { LRParser } from "npm:@lezer/lrUpgraded to Fresh 1.60 but TailwindCSS not renderingI updated my codebase to Fresh 1.60 using TailwindCSS instead of twind. When I pushed the code to DeOptimize for Prod simple static vanilla JS script - WebServer App with Oak + DEJSUsing DEJS to render views. Those views are served by Oak, according to the defined routes. What is ReadableStream passed to an island component argument becomes an empty objectI am passing `ReadableStream` to an island component argument becomes an empty objectdeno.jsonc "unstable" format?I added this entry to my `deno.jsonc`: ```json "unstable": [ "broadcast-channel", "ffi", "fs"Signal value not updating from inside of `for await of` loop inside of an IIFE```ts // routes/connect.tsx import type { FunctionComponent } from 'preact' import type { PageProps Pricing Question - Is my pro account applied to my Orgs?Just recently purchased a pro account cause I thought a project would benefit from the extra firepowRecommended `denoland/deno` contributor editor setupI have a problem with deno trying to redefine itself via random `declare namespace Deno { ... }` thrHow to enable "WebSocketStream" using deno.json fileI want to enable "WebSocketStream" using deno.json's "unstable" array option.