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

Uncaught exception with latest version crashes container #4158

Open
somesylvie opened this issue Nov 11, 2024 · 5 comments
Open

Uncaught exception with latest version crashes container #4158

somesylvie opened this issue Nov 11, 2024 · 5 comments

Comments

@somesylvie
Copy link

Version

4.0.6543 and 4.0.6594 (even though 6543 is the 'latest' on the NPM website, when we run npm install -g azure-functions-core-tools without specifying a version, we end up with the unlisted 6594)

Description

When running an azure function docker container, we recently started to see this error, which then crashes the container: terminate called after throwing an instance of 'PAL_SEHException'
Nothing in the Azure function or its configuration has changed recently. When we explicitly specify an older version of the core tools (such as 4.0.6280), we don't have any issues

Steps to reproduce

Run the azure function via docker compose: https://github.com/CDCgov/reportstream-sftp-ingestion/blob/main/docker-compose.yml#L65
Note that the installed version of core tools is the unlisted 6594, though we see the PAL_SEHException with version 6543 as well
We do not get the error if we change line 76 to npm install -g [email protected]
This is happening for at least 3 engineers on my team, all on Mac (either M1 or M3)

@liliankasem
Copy link
Member

Thanks for reporting the issue. I am able to repro and see the same problem reported (running on a Mac (M3)), and we were not able to repro on Windows so it does seem to be an amd64 related issue.

Interestingly, the last run I did threw a new exception:

The type initializer for 'Microsoft.Extensions.DependencyInjection.DependencyInjectionEventSource' threw an exception.

Versions 4.0.6543 and 4.0.6594 of the core tools both use the new out-of-proc host so there could be many things that started causing this problem. I will continue to investigate and let you know if any progress is made.

@liliankasem
Copy link
Member

liliankasem commented Nov 13, 2024

@somesylvie question about your scenario. Why are you installing core tools in the container? I was looking at the code you shared:

https://github.com/CDCgov/reportstream-sftp-ingestion/blob/689c937b4b24c26a4941e3b9566cd5e29b3cf33f/docker-compose.yml#L65

And you should be able to run the application just fine without command since the image will start your application e.g:

  azure-function:
    image: mcr.microsoft.com/azure-functions/node:4-node20
    volumes:
      - ./azure_functions:/home/site/wwwroot
    ports:
      - "7072:7071"
    environment:
      AzureWebJobsScriptRoot: /home/site/wwwroot
      AzureFunctionsJobHost__Logging__Console__IsEnabled: true
      AzureWebJobs.HttpExample.Disabled: "true"
      AzureWebJobsStorage: DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://sftp-Azurite:10000/devstoreaccount1;QueueEndpoint=http://sftp-Azurite:10001/devstoreaccount1;TableEndpoint=http://sftp-Azurite:10002/devstoreaccount1; # pragma: allowlist secret
      AZURE_STORAGE_CONNECTION_STRING: DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://sftp-Azurite:10000/devstoreaccount1;QueueEndpoint=http://sftp-Azurite:10001/devstoreaccount1; # pragma: allowlist secret
    networks:
      - sftp
    depends_on:
      azure-cli:
        condition: service_completed_successfully
      sftp-server:
        condition: service_started

Edit: If it's because of typescript, you can build via a Dockerfile i.e.

 FROM mcr.microsoft.com/azure-functions/node:4-node20

 ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
    AzureFunctionsJobHost__Logging__Console__IsEnabled=true

 COPY . /home/site/wwwroot

 RUN cd /home/site/wwwroot && \
    npm install && \
    npm run build 

Updated service in compose:

  azure-function:
    build:
      context: .
      dockerfile: ./azure_functions/Dockerfile

@somesylvie
Copy link
Author

@liliankasem it's been months since we set this all up so I don't remember the details of why it's set up the way it is, but without the whole command section or without just the core tools install, we get this error:

2024-11-13T12:17:47-06:00 fail: Host.Startup[402]
2024-11-13T12:17:47-06:00       The 'caDphTimerTrigger' function is in error: Can't figure out which ctor to call.

With the updated service and Dockerfile you suggested, we get these errors:

STEP 4/5: RUN cd /home/site/wwwroot &&     npm install &&     npm run build
npm error code ENOENT
npm error syscall open
npm error path /home/site/wwwroot/package.json
npm error errno -2
npm error enoent Could not read package.json: Error: ENOENT: no such file or directory, open '/home/site/wwwroot/package.json'
npm error enoent This is related to npm not being able to find a file.
npm error enoent
npm error A complete log of this run can be found in: /home/.npm/_logs/2024-11-13T18_13_35_498Z-debug-0.log
building at STEP "RUN cd /home/site/wwwroot &&     npm install &&     npm run build": while running runtime: exit status 254

Error: executing /opt/homebrew/bin/docker-compose -f /Users/sschuresko/Documents/GitHub/reportstream-sftp-ingestion/docker-compose.yml -p reportstream-sftp-ingestion up -d azure-function: exit status 1
`docker-compose` process finished with exit code 1

@liliankasem
Copy link
Member

Hmm, for the second error that's my bad, the context should be the azure_functions folder:

    build:
      context: ./azure_functions
      dockerfile: Dockerfile

I'm not sure about the first error though "Can't figure out which ctor to call" - will investigate this

@liliankasem
Copy link
Member

Hi @somesylvie - I found the resolution for your original docker-compose file. You need to add this environment variable:

environment:
      DOTNET_EnableWriteXorExecute: 0

I found the resolution here: dotnet/runtime#103063 (comment)

It seems to be specifically related to docker containers running on arm64 mac.

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

2 participants