zing
zing
DDeno
Created by zing on 1/23/2025 in #help
Different behaviour between Node and Deno with npm package
I'd like to use deno for a project that requires packages which are only available on npm. The issue I'm having is that executing the same script on deno and node is producing different results. - on node, the execution produces the expected results(some "forward" logs) - on deno, the execution pauses for a second at startup and then exits with no logs The script I'm working on is as follows: ```ts import { createChainSynchronizationClient, createInteractionContext } from 'npm:@cardano-ogmios/client' export const createContext = () => createInteractionContext( err => console.error(err), () => console.log("Connection closed."), { connection: { host: "<url>" , port: 443, tls: true } } ); export async function runExample() { const context = await createContext(); // console.log('here') const client = await createChainSynchronizationClient(context, { rollForward: async () => { console.log("forward") }, rollBackward: async () => { console.log("backward") } }); await client.resume(); } runExample() ``` uncommenting the console.log('here') and running with deno reveals the script isn't getting there, so presumably something is being held up inside createContext, which is calling createInteractoinContext(..)`. Obviously this is a function in the lib so I'm not expecting anyone to know whats wrong, but I was hoping someone with knowledge about the way deno interacts with npm packages might suggest what I should look for within the lib that could cause this 'silent exit'? thanks
2 replies
DDeno
Created by zing on 1/14/2025 in #help
Relative import path "oak/router" not prefixed with / or ./ or ../ and not in import map
I get the above message when attempting to deploy to Deno Deploy via github actions. The same does not occur when running locally with deno run -A src/main.ts. deploy.yaml:
# ...
- name: Upload to Deno Deploy
uses: denoland/deployctl@v1
with:
project: "<proj name>"
entrypoint: "./src/main.ts"
root: ""
import-map: "./deno.json"
# ...
- name: Upload to Deno Deploy
uses: denoland/deployctl@v1
with:
project: "<proj name>"
entrypoint: "./src/main.ts"
root: ""
import-map: "./deno.json"
deno.json:
// ...
"imports": {
"@std/assert": "jsr:@std/assert@1",
"@std/dotenv": "jsr:@std/dotenv",
"@std/path": "jsr:@std/path",
"@types/pg": "npm:@types/pg@^8.11.10",
"drizzle-kit": "npm:drizzle-kit@^0.30.1",
"drizzle-orm": "npm:drizzle-orm@^0.38.3",
"oak": "jsr:@oak/oak@17.0.0",
"dotenv": "https://deno.land/x/dotenv@v3.2.2/mod.ts",
"deno-postgres": "https://deno.land/x/postgres@v0.19.3/mod.ts",
"joi": "npm:joi@17.13.3",
"pg": "npm:pg@^8.13.1"
}
// ...
"imports": {
"@std/assert": "jsr:@std/assert@1",
"@std/dotenv": "jsr:@std/dotenv",
"@std/path": "jsr:@std/path",
"@types/pg": "npm:@types/pg@^8.11.10",
"drizzle-kit": "npm:drizzle-kit@^0.30.1",
"drizzle-orm": "npm:drizzle-orm@^0.38.3",
"oak": "jsr:@oak/oak@17.0.0",
"dotenv": "https://deno.land/x/dotenv@v3.2.2/mod.ts",
"deno-postgres": "https://deno.land/x/postgres@v0.19.3/mod.ts",
"joi": "npm:joi@17.13.3",
"pg": "npm:pg@^8.13.1"
}
src/main.ts
import { Router } from "oak/router";
// ...
import { Router } from "oak/router";
// ...
I know what the error means and I've fixed it before in other cases. From what I can see my configuration is correct, so I'm trying to figure out why I might be getting it only in the action execution. Could anyone lend an eye? thanks
5 replies
DDeno
Created by zing on 11/17/2024 in #help
Sequential queue processing with Deno KV listenQueue?
I'm working on an API endpoint that needs to process lots of calls every second. I want to make this call asynchronous so that the API returns fast and I can offload the data to be processed in the background, so I thought of using Deno.kv queues(https://docs.deno.com/deploy/kv/manual/queue_overview/). The only issue is that there is a lot of async code inside the processing jobs, and when I queue up a lot of them they seem to overlap in processing, which causes issues when accessing shared resources(db connections specifically). Is there a way to make kv.listenQueue process each entry in sequence? This is effectively my queue code:
const kv = await Deno.openKv();

kv.listenQueue(async (msg: EvaluateRequest) => { await service.evaluate(msg) })
const kv = await Deno.openKv();

kv.listenQueue(async (msg: EvaluateRequest) => { await service.evaluate(msg) })
3 replies
DDeno
Created by zing on 7/11/2023 in #help
Fresh pattern help
Could anyone possibly help guide me to understand the 'freshest' pattern for the following, please? When a user hits / I load a login page, and once he submits the form, the server generates some session data in the POST handler for /, and then redirects(send back a 303) to /chat. There is an island on /chat which needs to contain the session data. How would I redirect from the form POST handler, to the /chat page and make sure that my state is passed to the island? In react or similar I would handle the 'form submission' in javascript and cache the returned session data before redirecting to /chat. Since fresh seems to promote the use of native forms I'm trying to learn how I would handle this situation. I'm thinking of setting a cookie in the redirect, to then be sent with the /chat GET, which I can use to return the page with session data inside. Is that common? Thanks!
7 replies