mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
fix(core)!: Bind worker server to IPv4 (#11087)
This commit is contained in:
@@ -5,7 +5,6 @@ import type { InstanceSettings } from 'n8n-core';
|
||||
import { AssertionError } from 'node:assert';
|
||||
import * as http from 'node:http';
|
||||
|
||||
import { PortTakenError } from '@/errors/port-taken.error';
|
||||
import type { ExternalHooks } from '@/external-hooks';
|
||||
import type { PrometheusMetricsService } from '@/metrics/prometheus-metrics.service';
|
||||
import { bodyParser, rawBodyReader } from '@/middlewares';
|
||||
@@ -34,7 +33,7 @@ describe('WorkerServer', () => {
|
||||
beforeEach(() => {
|
||||
globalConfig = mock<GlobalConfig>({
|
||||
queue: {
|
||||
health: { active: true, port: 5678 },
|
||||
health: { active: true, port: 5678, address: '0.0.0.0' },
|
||||
},
|
||||
credentials: {
|
||||
overwrite: { endpoint: '' },
|
||||
@@ -59,8 +58,11 @@ describe('WorkerServer', () => {
|
||||
).toThrowError(AssertionError);
|
||||
});
|
||||
|
||||
it('should throw if port taken', async () => {
|
||||
it('should exit if port taken', async () => {
|
||||
const server = mock<http.Server>();
|
||||
const procesExitSpy = jest
|
||||
.spyOn(process, 'exit')
|
||||
.mockImplementation(() => undefined as never);
|
||||
|
||||
jest.spyOn(http, 'createServer').mockReturnValue(server);
|
||||
|
||||
@@ -69,18 +71,19 @@ describe('WorkerServer', () => {
|
||||
return server;
|
||||
});
|
||||
|
||||
expect(
|
||||
() =>
|
||||
new WorkerServer(
|
||||
globalConfig,
|
||||
mock(),
|
||||
mock(),
|
||||
mock(),
|
||||
externalHooks,
|
||||
instanceSettings,
|
||||
prometheusMetricsService,
|
||||
),
|
||||
).toThrowError(PortTakenError);
|
||||
new WorkerServer(
|
||||
globalConfig,
|
||||
mock(),
|
||||
mock(),
|
||||
mock(),
|
||||
externalHooks,
|
||||
instanceSettings,
|
||||
prometheusMetricsService,
|
||||
);
|
||||
|
||||
expect(procesExitSpy).toHaveBeenCalledWith(1);
|
||||
|
||||
procesExitSpy.mockRestore();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -89,8 +92,9 @@ describe('WorkerServer', () => {
|
||||
const server = mock<http.Server>();
|
||||
jest.spyOn(http, 'createServer').mockReturnValue(server);
|
||||
|
||||
server.listen.mockImplementation((_port, callback: () => void) => {
|
||||
callback();
|
||||
server.listen.mockImplementation((...args: unknown[]) => {
|
||||
const callback = args.find((arg) => typeof arg === 'function');
|
||||
if (callback) callback();
|
||||
return server;
|
||||
});
|
||||
|
||||
@@ -123,8 +127,9 @@ describe('WorkerServer', () => {
|
||||
const server = mock<http.Server>();
|
||||
jest.spyOn(http, 'createServer').mockReturnValue(server);
|
||||
|
||||
server.listen.mockImplementation((_port, callback: () => void) => {
|
||||
callback();
|
||||
server.listen.mockImplementation((...args: unknown[]) => {
|
||||
const callback = args.find((arg) => typeof arg === 'function');
|
||||
if (callback) callback();
|
||||
return server;
|
||||
});
|
||||
|
||||
@@ -177,8 +182,9 @@ describe('WorkerServer', () => {
|
||||
prometheusMetricsService,
|
||||
);
|
||||
|
||||
server.listen.mockImplementation((_port, callback: () => void) => {
|
||||
callback();
|
||||
server.listen.mockImplementation((...args: unknown[]) => {
|
||||
const callback = args.find((arg) => typeof arg === 'function');
|
||||
if (callback) callback();
|
||||
return server;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user