oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.48k stars 2.71k forks source link

pulsar-client not working #11943

Open Akumzy opened 3 months ago

Akumzy commented 3 months ago

What version of Bun is running?

1.1.13

What platform is your computer?

Darwin 23.5.0 arm64 arm

What steps can reproduce the bug?

Install Pulsar using docker

docker run -it \
-p 6650:6650 \
-p 8080:8080 \
--mount source=pulsardata,target=/pulsar/data \
--mount source=pulsarconf,target=/pulsar/conf \
apachepulsar/pulsar:3.3.0 \
bin/pulsar standalone

Install pulsar-client

bun add pulsar-client

Run code

// pulsar.ts

const Pulsar = require('pulsar-client')

const client1 = new Pulsar.Client({
  serviceUrl: 'pulsar://localhost:6650',
})
async function main() {
  try {
    // Create a producer
    const producer = await client1.createProducer({
      topic: 'my-topic',
    })

    // Send messages
    for (let i = 0; i < 10; i += 1) {
      const msg = `my-message-${i}`
      producer.send({
        data: Buffer.from(msg),
      })
      console.log(`Sent message: ${msg}`)
    }
    await producer.flush()

    await producer.close()
    await client1.close()
  } catch (error) {
    console.log(error)
  }
}
main()

What is the expected behavior?

Running with ts-node

$ npx ts-node pulsar.ts                                                                            
Sent message: my-message-0
Sent message: my-message-1
Sent message: my-message-2
Sent message: my-message-3
Sent message: my-message-4
Sent message: my-message-5
Sent message: my-message-6
Sent message: my-message-7
Sent message: my-message-8
Sent message: my-message-9

What do you see instead?


$ bun pulsar.ts        
4 |   serviceUrl: 'pulsar://localhost:6650',
5 | })
6 | async function main() {
7 |   try {
8 |     // Create a producer
9 |     const producer = await client1.createProducer({
                                       ^
error: Error
      at /Users/user/Github/[redacted]/pulsar.ts:9:36
      at main (/user/akuma/Github//[redacted]pulsar.ts:6:23)
      at /Users/user/Github//[redacted]/pulsar.ts:29:1

Additional information

No response

geoffhendrey commented 6 days ago

I have the same issue