deploy_feedback icon indicating copy to clipboard operation
deploy_feedback copied to clipboard

help debugging a type error

Open EdAyers opened this issue 3 years ago • 0 comments

I have a deployment that depends on kafkasaur. It connects and runs correctly on my local machine, but when it runs in deno deploy I get an error message

TypeError: Cannot read properties of undefined (reading 'deno')
    at https://deno.land/[email protected]/node/process.ts:76:108

I am sure that there is a dependency issue with kafkasaur somewhere since it hasn't been updated in a while. I'm not expecting deno deploy to support this obscure package, but I don't know how to hunt down the bug for myself since I can't reproduce this error locally. I managed to remove the above error by replacing each use of node/process with the deno equivalent in the kafkasaur library. However it's replaced with another message that I am stumped by:

TypeError: Class extends value undefined is not a constructor or null
    at https://deno.land/[email protected]/io/readers.ts:7:74

I can't find any reference to https://deno.land/[email protected]/io/readers.ts in my source or kafkasaur. Do you have any tips for how I can reproduce the environment that deno deploy is using so I can debug this without needing to push to deno deploy each time to check if it works.

mwe

I have a server running on deno deploy, it crashes when I call run in the below module, which is the tutorial example on the kafkasaur homepage. It works if I run locally.

//producer example
import { Kafka } from "https://deno.land/x/kafkasaur/index.ts"

console.log('imported Kafka')

const kafka = new Kafka({
    clientId: 'my_mwe_client',
    brokers: [Deno.env.get('BOOTSTRAP_SERVER')!],
    ssl: true,
    connectionTimeout: 10000,
    authenticationTimeout: 10000,
    sasl: {
        mechanism: 'plain',
        username: Deno.env.get('API_KEY')!,
        password: Deno.env.get('API_SECRET')!,
    }
})

const producer = kafka.producer();

export const run = async () => {
    await producer.connect();
    await producer.send({
        topic: 'test1',
        messages: [{
            key: 'key',
            value: 'hello there',
            headers: { 'correlation-id': `${Date.now()}` }
        }]
    })
    console.log('sent message')
}

note I don't see a log imported Kafka so I think something went wrong in parsing the module

versions

Local:

deno 1.23.3 (release, aarch64-apple-darwin)
v8 10.4.132.8
typescript 4.7.4

EdAyers avatar Jul 15 '22 10:07 EdAyers