Deno

D

Deno

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

Join

deno lint doesn't notice function call to unimported function

if I put "foo()" into test.js and run "deno lint test.js" I was expecting it to say "function foo() is not defined" or similar??
No description

Dynamic KV queue listener removal

It is possible to add listeners dynamically, but it seems impossible to remove them. I am creating listeners dynamically to process incoming messages from incoming WebSocket events. Each WebSocket client has an ID, and I want to create a queue dynamically for each ID when it connects, then process items in each queue sequentially to avoid concurrency issues arising from multiple rapid messages being received from the same client. However, if the connection is lost, I will need to create a new listener with a new WebSocket instance, so it can continue to process messages on the new connection. ...

kv#listenQueue logs ""KV Connect does not support queues" and errors when the listener is triggered

The error is: ``` error: Uncaught (in promise) Error: Enqueue operations are not supported in KV Connect. await kv.enqueue(incoming); ^...

deno install error for Nextjs Project

I'm using Deno 2.0.6 for now. But after I created Next.js app with create-next-app, I cd into the folder, deleted node_modules folder and run deno install --allow-scripts to re-install all modules with deno, but it give me the following error below: ``` error: script 'install' in 'sharp@0.33.5' failed with exit code 1 stderr:...

Piping two TCP connections to each other

Hey, I'm messing around trying to create a proxy in deno. I want to take an incoming connection, use some logic to decide how to route it, and then create an outgoing connection to pass it to. I have some code like this right now: ```ts...

auto import in VSCode/Zed (general LSP support for auto importing)

Hi all. I'm working with a fresh Deno project in VSCode and can't seem to get import autocompletes to work. All other LSP functionality seems to be working correctly. I have the following deno.json ```json { "tasks": {...

Docs on deno cache

Hi all, I’m confused about the state of the deno cache subcommand. It seems that the online docs are redirecting to deno install now, but $ deno help cache still gives info in v2.0.6. Is deno cache going away, to be replaced by deno install?

How to get User Information (or access token) for a oAuth session leveraging deno_kv_oauth and Fresh

It looks like the demo for Auth0 and Fresh linked on the deno_kv_oauth denoland page (https://github.com/denoland/fresh-deno-kv-oauth-demo) uses v@0.6.1 which is older than the current version of v@0.10.0. When trying to use v@0.10.0 it appears there were a bunch of breaking changes but no update to the demos or docs on how to leverage those changes or port the code. The shared plugin in fresh.ts was removed, but guidance was provided how to write and include your own, so no issue there. However, it looks like getSessionAccessToken has been removed, as well as any way to get information about the OAuth session itself (if I could get the access token I could get the user information from Auth0's own APIs.) In looking in JSR, kv_auth is v0.11.0, no idea if anything has changed between that one and the one on denoland. If I force everything to v0.6.1, I can get it to work with the old APIs. Is that my only option right now?...

How to resolve this?

Whenever I use npm install, these errors that seem to be related to deno somehow appear. Any thoughts? command: npm install vite @=Ingalless=...
No description

How to install deno with auto yes?

I am creating a setup script, and part of the installation process involves answering the question 'Do you want to edit shell configs to add Deno to the PATH?', which prevents my script from proceeding to the next task.

Intellisense not working for typescript react.

I ran this to create a new Vite React project: What I did: ``` deno run -A npm:create-vite@latest --template react-ts deno install...

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) ```ts import { Hono } from 'hono'...

Is there any way to limit write access of the `deno run` execution to its `Deno.makeTempDir` calls?

At the moment, the only way to enable Deno.makeTempDir() seem to either using --allow-write (writing to any file/dir path), or explicitly creating and maintaining a root temp folder and update all Deno.makeTempDir calls with a { dir: $MY_ROOT_TEMP_DIR } option. If there was a way to access the effective global temp root of Deno on the system, at least we could start with --allow-write=DENO_TEMP_ROOT, where DENO_TEMP_ROOT would be set via a deno call. Can anyone think of any other options here?...

Start a new Vite React project

Hi! Should https://docs.deno.com/runtime/tutorials/how_to_with_npm/react/ work out of the box? I am trying to get it to run with vscode but even if it runs there are a lot of small problems with it out of the box: - svgs are not recognized as valid resources - the react UMD is missing so everything is recognized as an error - doesn't generate a deno.json for me at all...

How can I do simple image recognition with Deno?

It's some very simple recognition, i don't need to recognize cats or dogs or people, just a few set of images within a bigger image and the quantity of each. Imagine counting the totals of a loot drop in game. It's that simple....

Skipping time in tests; time delay setTimeout setInterval

(the title is just so people can get to this one easier by using search) I have a deadline/delay based (@std/async) functionality and in tests I want to skip time (so I don't have to pass lower values for timeouts). I want something like jest's advanceTimersByTime...

What is the best way to mock an internal import?

Hello! I'm working with Deno and I love it so far, but I've run into one issue I can't seem to figure out, regarding testing and mocking internal packages. I'd like to be able to mock imports from other files, but I'm not sure what the best way to do it is. I have a db.ts file with some Sequelize classes exported (ADatabase and BDatabase), and I use them in another class in another file (ManagerClass in manager.ts). I'd like to be able to mock the Sequelize classes ADatabase and BDatabase, or at least the upsert methods on those classes. But, the examples in the documentation for mocking don't really give examples on how to mock something without reimplementing it (they have their internal functions on a _internals object). Am I supposed to go through my ManagerClass and change how I call each method, so I can easily replace those functions with stubbed/spied versions? Or can I change the self param on stub() to globalThis? I'm really not sure which is the correct way, or if it will even work. Please help me clear up this confusion. Thank you!...

Issue with ZMQ

Code to reproduce ```ts import { Pull } from "zeromq" console.log("Hello, world!")...

Deno project source control

Should I include deno.lock in the source control? Afaik, it is generated everytime deno install is used.

Deploying Deno as a frontend app

Hey all I'm currently working on a little personal project with a React Vite frontend running on Deno and was wondering if anyone had any recommendations on a service to use for deployment/hosting? I have tried and successfully been able to use Deno Deploy for the front/backend but I found that the frontend part of app doesn't support browser routing which is a necessary requirement for my project. I wanted to try using another service like Vercel but it seems like it doesn't support the Deno runtime for non-API applications at the moment. It seems like so far it might just be easier to go back to using npm/yarn for my frontend, while only using Deno for my backend web server, but I wanted to see if anyone out there had any suggestions. Thanks!...