Skip to content

Commit e3856e0

Browse files
committed
fix timing issue with unit test fix
1 parent 5ae4bd2 commit e3856e0

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/eventHandlers/WorkerInitHandler.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,14 @@ export class WorkerInitHandler extends EventHandler<'workerInitRequest', 'worker
6363
export function logColdStartWarning(channel: WorkerChannel, delayInMs?: number): void {
6464
// On reading a js file with function code('require') NodeJs tries to find 'package.json' all the way up to the file system root.
6565
// In Azure files it causes a delay during cold start as connection to Azure Files is an expensive operation.
66-
if (
67-
process.env.WEBSITE_CONTENTAZUREFILECONNECTIONSTRING &&
68-
process.env.WEBSITE_CONTENTSHARE &&
69-
process.env.AzureWebJobsScriptRoot
70-
) {
66+
const scriptRoot = process.env.AzureWebJobsScriptRoot;
67+
if (process.env.WEBSITE_CONTENTAZUREFILECONNECTIONSTRING && process.env.WEBSITE_CONTENTSHARE && scriptRoot) {
7168
// Add delay to avoid affecting coldstart
7269
if (!delayInMs) {
7370
delayInMs = 5000;
7471
}
7572
setTimeout(() => {
76-
access(path.join(process.env.AzureWebJobsScriptRoot!, 'package.json'), constants.F_OK, (err) => {
73+
access(path.join(scriptRoot, 'package.json'), constants.F_OK, (err) => {
7774
if (isError(err)) {
7875
channel.log({
7976
message:

0 commit comments

Comments
 (0)