Skip to content

req.(connection|socket).remotePort is not supported #102

@jimmyolo

Description

@jimmyolo

server listen on unix_socket, if access the req.ip,
will throw the RangeError: Offset is outside the bounds of the DataView. due to req.rawIp is an empty ArrayBuffer(0)

RangeError: Offset is outside the bounds of the DataView
    at DataView.prototype.getUint16 (<anonymous>)
    at get parsedIp (/home/jimmy/Projects/playground/node_modules/ultimate-express/src/request.js:259:26)
    at get ip (/home/jimmy/Projects/playground/node_modules/ultimate-express/src/request.js:174:25)
    at /home/jimmy/Projects/playground/unix_socket/index.js:14:19
    at next (/home/jimmy/Projects/playground/node_modules/ultimate-express/src/router.js:543:37)
    at /home/jimmy/Projects/playground/node_modules/ultimate-express/src/router.js:564:17
    at new Promise (<anonymous>)
const express = require('ultimate-express')

const { fetch, Agent } = require('undici');
const http = require('node:http');

const app = express();

app.get('/test', (req, res) => {
  res.send('Hello, World!');
});

app.listen('/tmp/app.sock', (t) => {
  console.log('Server is running on Unix socket', t);
})

// fetch('http://localhost/test', {
//   dispatcher: new Agent({
//     connect: {
//       socketPath: '/tmp/app.sock'
//     }
//   })
// }).then(async (resp) => {
//   console.log(await resp.text())
// })


http.request({
  socketPath: '/tmp/app.sock',
  path: '/test',
}, (res) => {
  res.on('data', (data) => {
    console.log(data.toString());
  });
}).end();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions