Deno

D

Deno

Chat about Deno, a modern runtime for JavaScript and TypeScript.

Join

Deno event loop and gui application

Hi, I am trying to write custom gtk library in deno using gtk-rs and deno_runtime. I already have initial rendering of components but i am having trouble understanding how to setup event loop for gui application. Currently i am using tokio's new_current_thread and block_on on deno's execute_main_module but this way setTimeouts don't seem to be executed which I suspect is because there is no event loop. execute_main_module seems to already call run_event_loop but should i just call it in loop or is there a proper way to do it using tokio? and how does event_loop_middleware fit into all this?
The other slightly related question is how do i schedule updates from the button clicks if the click listener closure is setup in the #[op(v8)]? thanks for your help...

Simple type narrowing/type guard/assertion (?)

Is there really no simpler way of doing this without any and without external deps? ```ts export function isFooBarBaz( value: unknown,...

Import is "Not yet initialized?"

No idea what this means. First screenshot is error, second screenshot is problematic line, third screenshot is the thing being imported. I don't know why it's saying it "hasn't been initialized", never run into this problem before and not sure what it's even supposed to mean....

How are deno processes/isolates managed in Deploy?

Hi, I'm writing a multiplayer game in Deno and currently all of the game state is kept in module-scoped objects, there's no database or any other form of persistence, yet. It all works as expected when I'm developing locally, but sometimes when testing in Deno Deploy, it's as if there's multiple instances of the game running and which one I'm connecting to is random (using the same URL.) Does Deploy create multiple simultaneous isolates for the same deployment? Is the only solution to implement...

Cannot access web server from other network devices when compiled

Hello. Im kinda new to deno and i just compiled my first bigger project with deno, but when the task is running, i can access the website directly from my pc, but not from my phone, which is in the same network. This is my code: ``ts import {serve} from "https://deno.land/std@0.188.0/http/server.ts"; serve(handler, {port: Number(env.PORT), onListen: () => console.log(Listening on http://localhost:${env.PORT}`)});...

How to use chrome devtools / inspector with Deno?

Hello all! I'd like to profile my game server written in Deno to identify the hot spots. I see that https://github.com/denoland/deno/pull/4484 was closed, but having trouble pulling up info on how to use it....

Clear local KV store

How do I delete/clear the local database?

Deno.Command not working for application

Hello. Im trying to start an application using Deno.Command, but it for some reason doesnt work. The path itself functions normally even from powershell. ```ts // Get the application to start const application = body.application?.trim()?.replace(/\/g, "/");...

Uint8Array or Float32Array

Is there any significant difference between using a Float32Array and using a Uint8Array from the same buffer for FFI?

Can I create a Fresh project inside another Deno project?

I would like to create a dashboard for my application (a minecraft bot), and I would like to use fresh to do so. I want everything to be contained inside the app's directory, so could I create a fresh project inside my current project? and then start the HTTP server programmatically? Or is there a better solution for something like this?...

Sending proper Content-Type depending on file sent

Hello. Im new to Deno and TypeScript and i wanted to convert one of my older projects (NodeJs and JavaScript). Now, my plan is to send the requested file, which actually does work, but the response doesnt send the proper content-type. What do i have to do in order to get this working properly? ```ts const handler = async (req: Request): Promise<Response> => { const url = new URL(req.url);...

Reclaim an already registered module?

Is it possible to reclaim an already registered third party module? For example if the module that is already registered doesn’t get any updates or is deprecated?

Deno.readDir on current script even if used like an http package.

Hello !! I would like to do Deno.readDir and readFiles on files relative to the script that execute Deno.readDir even if the script lives in deno.land/x. How should I do it ? Any help is welcomed thank you.

Top level awaits for `import()`

How come to top-level awaits for import() not work? I found an issue on GitHub https://github.com/denoland/deno/issues/7649, but it doesn't seem like it was fixed

How to auto import on save?

This doesn't work: { "deno.enable": true, "deno.lint": true,...

Remove sink from stream

Is it at all possible to "undo" adding a sink on a stream? I am trying to make it so that once the writable stream fulfills some condition, it should stop reading from the readable. ```ts someProcess.stderr.pipeTo( new WritableStream({...

HTTPS w/ client certificate – works in Node.js, not in Deno

I am making an HTTPS call with a client certificate. It works great in Node.js, but when I try to do the equivalent in Deno, I get a TLS handshake error. Any ideas on what I'm doing wrong?

Using encrypted private keys with Deno

So it seems to me that Deno doesn't provide any helpers for making HTTPS requests with encrypted private keys. (This is readily available in Node.js!) Is it possible at all make HTTPS requests with encrypted private keys in Deno? Not exactly sure how all of TLS works, and on what level it would need to be implemented....

Error when using readline.question()

I get this error with the following code ```ts import process from 'node:process' import readline from 'node:readline' ...

Do we need lockfiles if all our dependencies are hosted on https://deno.land/x?

When I make a new Deno config, a lockfile is generated automatically and I don't understand why. I'm only using deno.land dependencies, which I think are immutable, and no NPM dependencies. Lockfiles are unwanted noise in my Git history. Is there any benefit to having it?