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'? thanks1 Reply
update: I dove into the lib code which was quite heavily reliant on the
isomorphic-ws
npm package(more specifically the ws
package). I created a replica replacing all the websocket code with the equivalents from the following deno package: https://deno.land/x/websocket@v0.1.4. This seems to work 🙂