Rocky_Mountain_Vending/.pnpm-store/v10/files/d0/b7bf96d13dce2343ffec079e2f14c01ec1c476acae97e1fce5a641d4e8fa4c76e0c34c9539d9e36747c8719bc87f56a7ac8f5a675d77317a158513c31ccaef
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

36 lines
1.2 KiB
Text

import { timing } from "./timing";
const DEFER_EVENT_LISTENER_TIME = 1000;
export const setConnectionTimeout = (request, reject, timeoutInMs = 0) => {
if (!timeoutInMs) {
return -1;
}
const registerTimeout = (offset) => {
const timeoutId = timing.setTimeout(() => {
request.destroy();
reject(Object.assign(new Error(`@smithy/node-http-handler - the request socket did not establish a connection with the server within the configured timeout of ${timeoutInMs} ms.`), {
name: "TimeoutError",
}));
}, timeoutInMs - offset);
const doWithSocket = (socket) => {
if (socket?.connecting) {
socket.on("connect", () => {
timing.clearTimeout(timeoutId);
});
}
else {
timing.clearTimeout(timeoutId);
}
};
if (request.socket) {
doWithSocket(request.socket);
}
else {
request.on("socket", doWithSocket);
}
};
if (timeoutInMs < 2000) {
registerTimeout(0);
return 0;
}
return timing.setTimeout(registerTimeout.bind(null, DEFER_EVENT_LISTENER_TIME), DEFER_EVENT_LISTENER_TIME);
};