bun icon indicating copy to clipboard operation
bun copied to clipboard

`socketPath` issue with node:http

Open robobun opened this issue 2 years ago • 5 comments

Building a docker extension and am using bun.serve which is working great when the front end wants to talk to the backend. But I want to initiate some UNIX socket requests and am having some issues doing that. What would be the best way to go about it?

Originally reported on Discord: UNIX socket requests in BUN

robobun avatar Sep 25 '23 22:09 robobun

went over to just using http.request and that still doesnt work in bun. So I'm wondering if socketPath as an option just didn't get implemented. What my code looks like:

import http from 'node:http';
​
async function getDockerContainers(): Promise<Container[]> {
  const options = {
    socketPath: '/var/run/docker.sock',
    method: 'GET',
    path: '/containers/json',
  };
  const data = await new Promise<Container[]>((resolve, reject) => {
    const req = http.request(options, res => {
      console.log(res);
      let rawData = '';
      res.on('data', chunk => {
        rawData += chunk;
      });
      res.on('end', () => {
        resolve(JSON.parse(rawData));
      });
    });
    req.end();
  });
  const containers = data;
​
  return containers;
}

Zampare avatar Sep 25 '23 22:09 Zampare

the dockerode package is unusable because of this bug.

hazelnutcloud avatar Oct 24 '23 10:10 hazelnutcloud

Duplicate of https://github.com/oven-sh/bun/issues/2853?

ImLunaHey avatar Oct 29 '23 01:10 ImLunaHey

Any update on this? Can't use dockerode

siinghd avatar Feb 11 '24 15:02 siinghd

+1, for dockerode

isaced avatar Feb 11 '24 15:02 isaced

+1 for dockerode is there any temp fix for this?

Anprotaku avatar Mar 06 '24 09:03 Anprotaku

please stop bumping this to leave a +1

ImLunaHey avatar Mar 06 '24 22:03 ImLunaHey