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 3
3
4
4
import { SetupOptions } from '../types' ;
5
5
import { AzFuncSystemError } from './errors' ;
6
+ import { tryGetCoreApiLazy } from './utils/tryGetCoreApiLazy' ;
6
7
import { workerSystemLog } from './utils/workerSystemLog' ;
7
8
8
9
let options : SetupOptions = { } ;
@@ -16,6 +17,16 @@ export function setup(opts: SetupOptions): void {
16
17
if ( setupLocked ) {
17
18
throw new AzFuncSystemError ( "Setup options can't be changed after app startup has finished." ) ;
18
19
}
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
+
19
30
options = opts ;
20
31
workerSystemLog ( 'information' , `Setup options: ${ JSON . stringify ( options ) } ` ) ;
21
32
}
Original file line number Diff line number Diff line change @@ -8,7 +8,8 @@ import { tryGetCoreApiLazy } from './tryGetCoreApiLazy';
8
8
9
9
export function workerSystemLog ( level : types . LogLevel , ...args : unknown [ ] ) : void {
10
10
const coreApi = tryGetCoreApiLazy ( ) ;
11
- if ( coreApi ) {
11
+ // NOTE: coreApi.log doesn't exist on older versions of the worker
12
+ if ( coreApi && coreApi . log ) {
12
13
coreApi . log ( level , 'system' , format ( ...args ) ) ;
13
14
} else {
14
15
fallbackLogHandler ( level , ...args ) ;
You can’t perform that action at this time.
0 commit comments