@outputai/core 0.10.1-next.69a0f11.0 → 0.10.1-next.af37678.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/worker/index.js +0 -2
- package/src/worker/index.spec.js +0 -1
- package/src/worker/proxy.js +0 -20
- package/src/worker/proxy.spec.js +0 -51
package/package.json
CHANGED
package/src/worker/index.js
CHANGED
|
@@ -12,7 +12,6 @@ import { initInterceptors } from './interceptors/index.js';
|
|
|
12
12
|
import { createChildLogger } from '#logger';
|
|
13
13
|
import { setupInterruptionHandler } from './interruption.js';
|
|
14
14
|
import { CatalogJob } from './catalog_workflow/catalog_job.js';
|
|
15
|
-
import { bootstrapFetchProxy } from './proxy.js';
|
|
16
15
|
import { mainEventBus } from '#bus';
|
|
17
16
|
import { BusEventType } from '#consts';
|
|
18
17
|
import { setupTelemetry } from './telemetry.js';
|
|
@@ -61,7 +60,6 @@ const execute = async () => {
|
|
|
61
60
|
const { activities } = await loadActivities( callerDir, workflows );
|
|
62
61
|
|
|
63
62
|
mainEventBus.emit( BusEventType.WORKER_BEFORE_START );
|
|
64
|
-
bootstrapFetchProxy();
|
|
65
63
|
|
|
66
64
|
log.info( 'Initializing tracing...' );
|
|
67
65
|
await initTracing();
|
package/src/worker/index.spec.js
CHANGED
|
@@ -145,7 +145,6 @@ vi.mock( './sinks.js', () => ( { sinks: {} } ) );
|
|
|
145
145
|
vi.mock( './catalog_workflow/index.js', () => ( { createCatalog: createCatalogMock } ) );
|
|
146
146
|
vi.mock( './bundler_options.js', () => ( { webpackConfigHook: vi.fn() } ) );
|
|
147
147
|
vi.mock( './interceptors/index.js', () => ( { initInterceptors: initInterceptorsMock } ) );
|
|
148
|
-
vi.mock( './proxy.js', () => ( { bootstrapFetchProxy: vi.fn() } ) );
|
|
149
148
|
vi.mock( './telemetry.js', () => ( { setupTelemetry: setupTelemetryMock } ) );
|
|
150
149
|
vi.mock( './interruption.js', () => ( { setupInterruptionHandler: setupInterruptionHandlerMock } ) );
|
|
151
150
|
vi.mock( './global_functions.js', () => ( { bindGlobalFunctions: bindGlobalFunctionsMock } ) );
|
package/src/worker/proxy.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { EnvHttpProxyAgent, setGlobalDispatcher } from 'undici';
|
|
2
|
-
import { createChildLogger } from '#logger';
|
|
3
|
-
|
|
4
|
-
const log = createChildLogger( 'Proxy' );
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Routes all `fetch()` calls (including those inside Temporal activities)
|
|
8
|
-
* through an HTTP/HTTPS proxy when standard proxy env vars are set.
|
|
9
|
-
* No-op when none are set.
|
|
10
|
-
*/
|
|
11
|
-
export const bootstrapFetchProxy = () => {
|
|
12
|
-
const httpProxyUrl = process.env.http_proxy ?? process.env.HTTP_PROXY;
|
|
13
|
-
const httpsProxyUrl = process.env.https_proxy ?? process.env.HTTPS_PROXY;
|
|
14
|
-
|
|
15
|
-
if ( httpProxyUrl?.length > 0 || httpsProxyUrl?.length > 0 ) {
|
|
16
|
-
log.info( 'Proxy env vars detected, setting up global fetch dispatcher EnvHttpProxyAgent', { httpProxyUrl, httpsProxyUrl } );
|
|
17
|
-
/* Ignore HTTP/2. Check: https://github.com/growthxai/output/issues/299 */
|
|
18
|
-
setGlobalDispatcher( new EnvHttpProxyAgent( { allowH2: false } ) );
|
|
19
|
-
}
|
|
20
|
-
};
|
package/src/worker/proxy.spec.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
2
|
-
|
|
3
|
-
const mockSetGlobalDispatcher = vi.fn();
|
|
4
|
-
const MockEnvHttpProxyAgent = vi.fn();
|
|
5
|
-
const mockLogger = { info: vi.fn(), warn: vi.fn(), error: vi.fn() };
|
|
6
|
-
|
|
7
|
-
vi.mock( 'undici', () => ( {
|
|
8
|
-
EnvHttpProxyAgent: MockEnvHttpProxyAgent,
|
|
9
|
-
setGlobalDispatcher: mockSetGlobalDispatcher
|
|
10
|
-
} ) );
|
|
11
|
-
|
|
12
|
-
vi.mock( '#logger', () => ( {
|
|
13
|
-
createChildLogger: () => mockLogger
|
|
14
|
-
} ) );
|
|
15
|
-
|
|
16
|
-
describe( 'worker/proxy', () => {
|
|
17
|
-
const proxyEnv = [ 'http_proxy', 'HTTP_PROXY', 'https_proxy', 'HTTPS_PROXY' ];
|
|
18
|
-
|
|
19
|
-
beforeEach( () => {
|
|
20
|
-
vi.clearAllMocks();
|
|
21
|
-
for ( const key of proxyEnv ) {
|
|
22
|
-
delete process.env[key];
|
|
23
|
-
}
|
|
24
|
-
} );
|
|
25
|
-
|
|
26
|
-
afterEach( () => {
|
|
27
|
-
vi.resetModules();
|
|
28
|
-
} );
|
|
29
|
-
|
|
30
|
-
it( 'does nothing when no proxy env vars are set', async () => {
|
|
31
|
-
const { bootstrapFetchProxy } = await import( './proxy.js' );
|
|
32
|
-
bootstrapFetchProxy();
|
|
33
|
-
|
|
34
|
-
expect( MockEnvHttpProxyAgent ).not.toHaveBeenCalled();
|
|
35
|
-
expect( mockSetGlobalDispatcher ).not.toHaveBeenCalled();
|
|
36
|
-
expect( mockLogger.info ).not.toHaveBeenCalled();
|
|
37
|
-
} );
|
|
38
|
-
|
|
39
|
-
it( 'sets global dispatcher when proxy URL is available', async () => {
|
|
40
|
-
process.env.HTTP_PROXY = 'http://proxy:8080/';
|
|
41
|
-
const { bootstrapFetchProxy } = await import( './proxy.js' );
|
|
42
|
-
bootstrapFetchProxy();
|
|
43
|
-
|
|
44
|
-
expect( MockEnvHttpProxyAgent ).toHaveBeenCalledWith( { allowH2: false } );
|
|
45
|
-
expect( mockSetGlobalDispatcher ).toHaveBeenCalledTimes( 1 );
|
|
46
|
-
expect( mockLogger.info ).toHaveBeenCalledWith(
|
|
47
|
-
'Proxy env vars detected, setting up global fetch dispatcher EnvHttpProxyAgent',
|
|
48
|
-
{ httpProxyUrl: 'http://proxy:8080/', httpsProxyUrl: undefined }
|
|
49
|
-
);
|
|
50
|
-
} );
|
|
51
|
-
} );
|