File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change 33
44import { SetupOptions } from '../types' ;
55import { AzFuncSystemError } from './errors' ;
6+ import { tryGetCoreApiLazy } from './utils/tryGetCoreApiLazy' ;
67import { workerSystemLog } from './utils/workerSystemLog' ;
78
89let options : SetupOptions = { } ;
@@ -16,6 +17,16 @@ export function setup(opts: SetupOptions): void {
1617 if ( setupLocked ) {
1718 throw new AzFuncSystemError ( "Setup options can't be changed after app startup has finished." ) ;
1819 }
20+
21+ if ( opts . enableHttpStream ) {
22+ // NOTE: coreApi.log was coincidentally added the same time as http streaming,
23+ // so we can use that to validate the host version instead of messing with semver parsing
24+ const coreApi = tryGetCoreApiLazy ( ) ;
25+ if ( coreApi && ! coreApi . log ) {
26+ throw new AzFuncSystemError ( `HTTP streaming requires Azure Functions Host v4.28 or higher.` ) ;
27+ }
28+ }
29+
1930 options = opts ;
2031 workerSystemLog ( 'information' , `Setup options: ${ JSON . stringify ( options ) } ` ) ;
2132}
Original file line number Diff line number Diff line change @@ -8,7 +8,8 @@ import { tryGetCoreApiLazy } from './tryGetCoreApiLazy';
88
99export function workerSystemLog ( level : types . LogLevel , ...args : unknown [ ] ) : void {
1010 const coreApi = tryGetCoreApiLazy ( ) ;
11- if ( coreApi ) {
11+ // NOTE: coreApi.log doesn't exist on older versions of the worker
12+ if ( coreApi && coreApi . log ) {
1213 coreApi . log ( level , 'system' , format ( ...args ) ) ;
1314 } else {
1415 fallbackLogHandler ( level , ...args ) ;
You can’t perform that action at this time.
0 commit comments