Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node process is making calls to Azure Files for package.json during cold start #449

Closed
safihamid opened this issue Oct 28, 2021 · 5 comments
Assignees
Milestone

Comments

@safihamid
Copy link

Cold Start profiles show calls directly to Azure files to try to read package.json file during specialization.
This happens even when content is deployed az zip and we are using zip cache.

Looks like node process looks at all these places to try to load the package.json file:

FileName
C:\Program Files (x86)\SiteExtensions\Functions\4.0.0\workers\node\dist\src\package.json
C:\Program Files (x86)\SiteExtensions\Functions\4.0.0\workers\node\dist\package.json
C:\Program Files (x86)\SiteExtensions\Functions\4.0.0\workers\node\package.json
C:\Program Files (x86)\SiteExtensions\Functions\4.0.0\workers\package.json
C:\Program Files (x86)\SiteExtensions\Functions\4.0.0\package.json
C:\Program Files (x86)\SiteExtensions\Functions\package.json
C:\Program Files (x86)\SiteExtensions\package.json
C:\Program Files (x86)\package.json
C:\package.json
\\somestorage.file.core.windows.net\someappname\site\package.json
\\somestorage.file.core.windows.net\someappname\package.json
@alrod
Copy link
Member

alrod commented Oct 28, 2021

I am wondering if node tries to find package.json on the function code load:
https://github.com/Azure/azure-functions-nodejs-worker/blob/v2.x/src/FunctionLoader.ts#L47

@anthonychu
Copy link
Member

I think this is standard behavior for Node. It uses package.json to figure out things like module system type (commonjs or module) and it'll search all parents to find it. It's searching from that location because workers\node\dist\srcnodejsWorker.js is the entry point. Not sure if we can prevent this but can probably limit it to a single read if we include a package.json in workers\node\dist\src.

@alrod
Copy link
Member

alrod commented Oct 29, 2021

To prove the theory I did not load function from file system but instead loaded hardcoded function from memory. It looks like we need some "empty" package.json added to the worker so it will be loaded from worker folder before going to AzureFiles:
MicrosoftTeams-image (1)

@safihamid validated that it works:
etls.zip

@ejizba
Copy link
Contributor

ejizba commented Dec 6, 2021

Addressed in Azure/azure-functions-host#7948

@ejizba ejizba added the P2 label Jan 28, 2022
@ejizba
Copy link
Contributor

ejizba commented Feb 9, 2022

Fixed in #501

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants