tomphttp/bare-server-node

Unknown errors causing super slow response times to requests

jackchristel opened this issue · 2 comments

Errors I recieve
AbortError: The operation was aborted
at EventTarget.onAbort (node:internal/streams/add-abort-signal:37:20)
at [nodejs.internal.kHybridDispatch] (node:internal/event_target:735:20)
at EventTarget.dispatchEvent (node:internal/event_target:677:26)
at abortSignal (node:internal/abort_controller:308:10)
at AbortController.abort (node:internal/abort_controller:338:5)
at ServerResponse. (/var/www/bareserver/node_modules/@tomphttp/bare-server-node/dist/V1.js:136:15)
... 3 lines matching cause stack trace ...
at Socket.emit (node:events:525:35) {
code: 'ABORT_ERR',
[cause]: DOMException [AbortError]: This operation was aborted
at new DOMException (node:internal/per_context/domexception:53:5)
at AbortController.abort (node:internal/abort_controller:336:18)
at ServerResponse. (/var/www/bareserver/node_modules/@tomphttp/bare-server-node/dist/V1.js:136:15)
at ServerResponse.emit (node:events:513:28)
at emitCloseNT (node:_http_server:965:10)
at Socket.onServerResponseClose (node:_http_server:277:5)
at Socket.emit (node:events:525:35)
at TCP. (node:net:322:12)
}

Code:

import createBareServer from "@tomphttp/bare-server-node";
import http from "node:http";

const httpServer = http.createServer();
const bareServer = createBareServer("/bare/", {logErrors: true});

httpServer.on("request", (req, res) => {
    if (bareServer.shouldRoute(req)) {
      bareServer.routeRequest(req, res);
    } else {
        res.writeHead(404).end();
    }
  });
  httpServer.on("upgrade", (req, socket, head) => {
    if (bareServer.shouldRoute(req)) {
      bareServer.routeUpgrade(req, socket, head);
    } else {
      socket.end();
      //return;
    }
  });


  httpServer.on("listening", () => {
    console.log('listening on http://localhost:${8081}/');
  });
  
  httpServer.listen({
    port: 8081
  });

Node Version: v18.15.0
Bare-Server-Node Version: v1.2.5

e9x commented

This error is shown due to the client aborting the request. It may appear to be slow if your console is being overwhelmed by errors, in which case I would just disable error logging.

Ok thanks, but it gets slow regardless of whether logging is enabled or disabled. I'm using this for the ultraviolet proxy, but using an old version of the scripts for that shouldn't cause this though?