bun icon indicating copy to clipboard operation
bun copied to clipboard

Implement some `undici` APIs

Open ThatOneBro opened this issue 2 years ago • 3 comments

Implementing these two classes in undici will unblock libraries like discord.js and @elastic/elasticsearch (as mentioned here: https://github.com/oven-sh/bun/issues/1749#issuecomment-1413262351)

  • [x] undici.Agent
  • [x] undici.Pool
  • [x] undici.request (Required for discord.js)
  • [ ] undici.Pool.request (Probably just calls undici.request polyfill)

ThatOneBro avatar Feb 04 '23 23:02 ThatOneBro

We can polyfill it, like with http.Agent

Jarred-Sumner avatar Feb 04 '23 23:02 Jarred-Sumner

We can polyfill it, like with http.Agent

Yeah is undici fetch just re-exporting global fetch? So basically we would just need to stub these two classes out?

ThatOneBro avatar Feb 04 '23 23:02 ThatOneBro

Exactly

Jarred-Sumner avatar Feb 04 '23 23:02 Jarred-Sumner

68 |   }
69 | 
70 |   async arrayBuffer() {
71 |     this.#consume();
72 | 
73 |     return await this.#response.arrayBuffer();
                    ^
TypeError: undefined is not a function
      at undici:73:17
      at arrayBuffer (undici:71:22)
      at parseResponse (/home/whynotdogie/dev/nodejs/discordjs/freart/node_modules/@discordjs/rest/dist/index.js:493:29)

I assume that this is being fixed.

WhyNotDogie avatar Jun 17 '23 16:06 WhyNotDogie

49 |             enumerable: true,
50 |             configurable: true,
51 |             writable: true,
52 |             value: void 0
53 |         });
54 |         Error.captureStackTrace(this, ConnectionError);
            ^
ConnectionError: Not implemented in bun
      at new ConnectionError (/home/username/project/api/node_modules/@elastic/transport/lib/errors.js:54:8)
      at /home/username/project/api/node_modules/@elastic/transport/lib/Transport.js:528:30
      at processTicksAndRejections (:1:2602)

Bun Version :1.0.0 @elastic/elasticsearch : ^8.6.0

Having this Error

Kabeer10 avatar Sep 12 '23 12:09 Kabeer10

These were all implemented. If you run into a "Not implemented" error, please open another issue so we can track it.

Electroid avatar Oct 25 '23 22:10 Electroid