Deno

D

Deno

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

Join

intercept an op rust-side and call the original fn

Hi, i'm using deno_core and some exts embedded in a desktop application, and am trying to replace an existing op with my own version in which i do some additional checks before calling to the original op's function. i can replace the op using Extension::middleware_fn, but i can't see a way to access the original op's function. the simplest way i can think to do this would be to modify the op2 macro to expose the raw function. am i missing something simpler? for context, i want to modify op_ws_create from deno_websocket to do a (potentially asynchronous) permission check, and add some default headers. i don't want to do it javascript-side because i worry that would be exploitable, but maybe it can be done safely (my js knowledge is far below my rust knowledge). i can't use the built-in WebSocketPermissions trait as it is a synchronous function (i guess i could modify it to be async instead)....

Why Deno runtime is differently when running locally or through Deno Cloud?

FYI: I did already post into the deploy feedback as well. Posting here as well to gain more visibility, but here's the link to the repo where you can reproduce in less than 5 minutes. https://github.com/uptownhr/tiny-url/commit/a9201732bbc95525588a17e93e0afdc720646dbc Locally,...

Deno JSR API package + CLI entrypoint "best-practices"

Hey πŸ‘‹ I have a package that is both a CLI and provides a JS API. Previously with deno.land/x, the JS API entrypoint would be in mod.ts and the CLI entrypoint in main.ts; something like: ...

Formatting with VSCode adds a tab instead of 2 spaces

Hi, I'm experiencing a weird behavior in VSCode. I'm formatting a new Typescript file however it adds a tab for indentation instead of 2 spaces, but formatting an existing file works. I have setup this config under deno.json: "fmt": { "indentWidth": 2 }...

Type-narrowing/covariance/contravariance

Why is it that 5 has type 5 but {five:5} has type {five:number} and not {five:5}?

Ensure error is of type unknown with Deno lint

I'm having an interesting issue in a catch (error) { block. The issue is resolved when I change it to error: unknown, as I then get a type error in the function I call later. When the error is any, I get no warning, and I'm quite sure I'll forget to manually add : unknown to all my errors, so I'm looking for a way to guard for this πŸ€”...

Why does Deno Deploy give you two urls

e.g. static-77-kjygrg7q7rxe.deno.dev and static-77.deno.dev

Deno - Cloudflare Pages compatibility?

I'm probably reading the denoflare docs wrong, but it seems to not specify whether it works with pages specifically. Am

Using bitbucket repositories as dependencies in Deno

I've seen guides about how to use github repositories and use them as dependencies but have not found one about bitbucket repositories. I did some attempts but failed to make the env variable DENO_AUTH_TOKENS work with the bitbucket "raw" url. Anyone with a working setup on this?

Trouble with serving HTMl on localhost

Hi, so I'm building a framework for SSR and I'm struggling with the following: When I clone my repo and run my example app with deno run --allow-net example.ts, and I open up any pages on localhost:8080/page{0-4}, I see a blank white screen. I have narrowed down the problem to lines 48-75 in the file linked below. Where am I going wrong? I tried a simple console.log from within the handler closure to no avail. What am I missing here? Link to the file: https://github.com/angeldollface/mina/blob/main/src/server.ts...

How do you define an op in rust to return a string?

``` #[deno_core::op2(async)] async fn op_fetch(#[string] req: String) -> String { async { "hello".to_string() }.await }...

onClick not staying with preact-render-to-string?

Hello, I'm trying to make an SSR application by rendering components to strings. However, I need a button to have some JavaScript capabilities and unfortunately Preact seems to be removing it. How can I work around this? I'd like to continue rendering it to a string if possible. Thanks!

Deno project suddenly won't launch in VS Code

I haven't changed anything in my project or environment except having done a brew update/upgrade, which may have updated Deno. Now when I try to launch my server code in VS Code, it doesn't run. There are no error messages or other indications of trouble, and the server runs fine if I launch it from the command line. I tried re-intializing the working folder with the Deno plug-in, but this did not change anything. This setup had been working for months. Any ideas?

Deno BYOW help with macOS [Solved] and X11

https://github.com/fazil47/deno_winit I'm trying to make Deno binding for winit for using WebGPU, it's working for Wayland and Windows but not for macOS and X11....

How can I add a flag into Deno Deploy in production?

Hi, I am wondering how do I add a flag in production on Deno deploy if I want to enable a certain flag?

Uploading Files to S3 Bucket usign deno-s3-lite-client

Hello, I have been trying to make a file upload controller with deno's s3 lite client but I am facing an issue with uploading the content type of my file. In their documentation, i can read that the way to use the putObject() fucntion is like this: `Deno.test({ name: "putObject() can stream a large file upload", fn: async () => {...

Deno.cron error

Hi I keep having an error on deno deploy where my cron job doesn't seem to execute well in production. I have server.ts where I import the cron job script:
import "./mongoTestCron.ts";
import "./mongoTestCron.ts";
...

How to rewrite this: `import * as base32 from "jsr:@std/encoding@0.224.3/base32.ts";`

I am migrating std from /x and I ran into this issue. What the correct way to import just base32.ts. For now I can do https://jsr.io/@std/encoding/0.224.3/base32.ts

Default export has no call signatures

I'm trying to import the default export from npm:@feathersjs/express, but Deno complains that the default export has no call signatures. ```ts // main.ts import express from "npm:@feathersjs/express";...

Catch/handle WebSocketStream connection reset error

How/where to catch this error? I am using WebSocketStream and catching on wss.opened and on wss.closed still this error is uncaught from somewhere -
error: Uncaught (in promise) WebSocketError: connection reset
at new WebSocketError (ext:deno_websocket/02_websocketstream.js:478:5)
at Object.pull (ext:deno_websocket/02_websocketstream.js:270:31)
at eventLoopTick (ext:core/01_core.js:168:7)
error: Uncaught (in promise) WebSocketError: connection reset
at new WebSocketError (ext:deno_websocket/02_websocketstream.js:478:5)
at Object.pull (ext:deno_websocket/02_websocketstream.js:270:31)
at eventLoopTick (ext:core/01_core.js:168:7)
...