kingbri
kingbri
DDeno
Created by kingbri on 11/19/2024 in #help
AbortSignals not working in Deno
Hi there, I'm trying to create a Hono server with a disconnect handler. When I cancel the request from my client, the abort signal from the raw Request object never changes to true. This code works on both Hono and Bun, so I think this is an issue with Deno's fetch API. See example below (requires Hono)
import { Hono } from 'hono'

const app = new Hono()

async function stall(stallTime = 3000) {
await new Promise(resolve => setTimeout(resolve, stallTime));
}

app.get('/hello', async (c) => {

// Should show up when hitting Cancel in Postman
c.req.raw.signal.addEventListener("abort", () => {
console.log("Aborted");
})

// Simulate a long-running task
await stall(10000);
return c.text("Hello from Hono!");
})

Deno.serve(app.fetch)
import { Hono } from 'hono'

const app = new Hono()

async function stall(stallTime = 3000) {
await new Promise(resolve => setTimeout(resolve, stallTime));
}

app.get('/hello', async (c) => {

// Should show up when hitting Cancel in Postman
c.req.raw.signal.addEventListener("abort", () => {
console.log("Aborted");
})

// Simulate a long-running task
await stall(10000);
return c.text("Hello from Hono!");
})

Deno.serve(app.fetch)
2 replies
DDeno
Created by kingbri on 11/7/2024 in #help
Cannot use import maps
Hi there, I'm trying to make a project root alias @ so I don't have to suffer through relative path import hell (../../../../file.ts) However, when I specify "@/": "./" in the imports section of deno.json, I get an error from VSCode stating this:
The import specifier can be remapped to "@/absolutePath/file.ts" which will resolve it via the active import map.
The import specifier can be remapped to "@/absolutePath/file.ts" which will resolve it via the active import map.
Therefore, I either have to use absolute imports for every file or use only relative imports. I want to be able to use both. Is converting the project root to @/ not possible without some sort of src directory? Thanks in advance.
2 replies
DDeno
Created by kingbri on 10/28/2024 in #help
Include DLL files in deno compile
I'm currently building a CLI application with Deno that I want to compile into a standalone executable which uses FFI. I learned about deno compile, but I'm also stuck on how to include the DLLs that are used via FFI in my output binary. I don't want to include the DLLs separately after the binary is built, but I want to be able to ship a single binary. For example, nexe.js allows users to add static files under resources https://github.com/nexe/nexe?tab=readme-ov-file#resources Can this be replicated in Deno?
2 replies