bun icon indicating copy to clipboard operation
bun copied to clipboard

Bun using restify: stream_wrap error

Open hfabio opened this issue 1 year ago • 8 comments

What version of Bun is running?

1.0.0+822a00c4d508b54f650933a73ca5f4a3af9a7983

What platform is your computer?

Linux 5.15.90.1-microsoft-standard-WSL2 x86_64 x86_64

What steps can reproduce the bug?

create an Api using restify in Bun.

those are the dependencies related to restify:

    "restify": "^11.1.0",
    "restify-cors-middleware": "^1.1.1",
    "restify-router": "^0.6.2",

and this is an example code:

import restify from "restify";
import corsMiddleware from "restify-cors-middleware";

const cors = corsMiddleware({
	preflightMaxAge: 5, //Optional
	origins: ["*"],
	allowHeaders: ["Origin", "X-Requested-With", "Content-Type", "Accept", "Authorization"],
	exposeHeaders: ["Origin", "X-Requested-With", "Content-Type", "Accept", "Authorization"],
});

//configure server name and version
const server = restify.createServer({
	name: "example",
	version: "0.1",
});

//configure cors
server.pre(cors.preflight);
server.use(cors.actual);

//configure restify
server.use(restify.plugins.acceptParser(server.acceptable));
server.use(restify.plugins.queryParser());
server.use(restify.plugins.bodyParser());

server.listen(port, async function () {
	console.log(Array(40).fill("\n").join("")); //clear screen
	console.log("Backend running at %s", server.url);
	//starts cron jobs
	cronController.startCronJobs();
});

What is the expected behavior?

to create a working http server.

What do you see instead?

this is the error I get:

↳ bun run src/server.ts
[0.15ms] ".env"
1 | (function (bindingName){"use strict";if(bindingName==="constants")return @processBindingConstants;const issue={fs:3546,buffer:2020,natives:2254,uv:2891}[bindingName];if(issue)throw new Error(`process.binding("${bindingName}") is not implemented in Bun. Track the status & thumbs up the issue: https://github.com/oven-sh/bun/issues/${issue}`);@throwTypeError(`process.binding("${bindingName}") is not implemented in Bun. If that breaks something, please file an issue and include a reproducible code sample.`)})
                       ^
TypeError: process.binding("stream_wrap") is not implemented in Bun. If that breaks something, please file an issue and include a reproducible code sample.
      at binding (:1:20)
      at /home/hfabio/Projetos/vsdbmv2/orchestrator/node_modules/handle-thing/lib/handle.js:17:11
      at globalThis (/home/hfabio/Projetos/vsdbmv2/orchestrator/node_modules/handle-thing/lib/handle.js:262:9)
      at require (:1:20)
      at /home/hfabio/Projetos/vsdbmv2/orchestrator/node_modules/spdy/lib/spdy/handle.js:4:4
      at globalThis (/home/hfabio/Projetos/vsdbmv2/orchestrator/node_modules/spdy/lib/spdy/handle.js:246:3)
      at require (:1:20)
      at /home/hfabio/Projetos/vsdbmv2/orchestrator/node_modules/spdy/lib/spdy.js:6:5

Additional information

debugging my project it only happens when running the restify, socket.io works fine and my project code as well, so probably it is something related to the way restify implements something under the hood

hfabio avatar Sep 11 '23 14:09 hfabio

Yeah had same issue with my restify server

sjonni1 avatar Sep 12 '23 16:09 sjonni1

Potentially fixed as part of https://github.com/oven-sh/bun/issues/4593, but it hasn't been released yet

Might be worth revisiting if this issues still exists when the associated fix is released

Edit: error still present with 1.0.2 which includes the PR mentioned

alif-mohdamir avatar Sep 14 '23 20:09 alif-mohdamir

version 1.04 still not working

(base) hfabio in orchestrator on  feature/convert-to-bun [!]
↳ bun -version
1.0.4
(base) hfabio in orchestrator on  feature/convert-to-bun [!]
↳ bun --revision
1.0.4+745b6b94ee56cad24d475799690cc9a89957d15b

hfabio avatar Oct 07 '23 19:10 hfabio

Having the same issue trying to run rest servers. Lot of people would love to use bun with a restify dependency.

electic avatar Oct 12 '23 20:10 electic

Any update on this? It's still present with 1.0.14.

todor-a avatar Nov 27 '23 13:11 todor-a

It's still present with 1.0.16.

hfabio avatar Dec 10 '23 18:12 hfabio

It's still present with 1.1.2.

joesdu avatar Apr 08 '24 10:04 joesdu

This prevents this package from working: https://www.npmjs.com/package/spdy

alxivnov avatar May 07 '24 19:05 alxivnov