I've created a port scanner project that doesn't work when published

loremtools.netlify.app/portscan

The tool currently works on my dev environment, however, on netlify the results do not appear. This current project is just random tools that I’m showcasing and I would love this one to work but I don’t know if it’s something that won’t because maybe netliify blocks this type of behavior? I’m also don’t know how to troubleshoot my back end issues in nuxt on netlify so if it’s not netlify blocking the traffic, I don’t really know how to go about troubleshooting the build on netlify - any help will be appreciated.

ok when using inspect tools it does appear that I’m getting a 502 Bad Gateway on the POST… Even though the node side is on the same exact app build it still treats this as legitimate network request. It’s obviously an issue with my configuration at this point. Any help would be apprecitated.

ok more details actual error:

{“errorType”:“LambdaTimeout”,“errorMessage”:“2025-02-17T17:54:34.617Z a1c6d02a-c619-4197-9c8a-0c9762675656 Task timed out after 10.02 seconds”}

it’s a nuxt deployment - no issues in dev but it is getting this timeout in netlify…

the function runs almost instantly in dev so hitting the 10 second timeout limit is kind of strange in this scenario

What exactly are you running inside your server-side functionality? Code examples would be useful to understand.

ah! yes I suppose that would help. here is my scan.js - thanks for any help:

import { defineEventHandler, readBody } from "h3";
import net from "net";

export default defineEventHandler(async (event) => {
  const { host, startPort, endPort } = await readBody(event);

  return new Promise((resolve, reject) => {
    const openPorts = [];
    let portsChecked = 0;

    for (let port = startPort; port <= endPort; port++) {
      const socket = net.createConnection(port, host);

      socket.on("connect", () => {
        openPorts.push(port);
        socket.destroy();
      });

      socket.on("error", (err) => {
        socket.destroy();
      });
      socket.on("close", () => {
        portsChecked++;
        if (portsChecked === endPort - startPort + 1) {
          resolve({ open_ports: openPorts });
        }
      });
    }
  });
});

Could you try setting a socket timeout to verify if that’s being hit:

socket.setTimeout(3000);
socket.on('timeout', () => {
  console.log('socket timeout');
  socket.end();
});