Azure / Azure/azure-functions-core-tools

Azure Function restarts host on start up causing it to crash out on MacOS when using --language-worker -- "--inspect=5858" flag

Open
#1,738 1 comment 0 reactions 0 assignees View on GitHub
investigate
Dominant language
C#
Stars
1.5k
Forks
498
Avg merge
5d 4h
Merged PRs (30d)
15

Description

Very reasy repro, just try to run the following;

> func host start --language-worker --inspect=5858

and an typescript watch (i.e. tsc -w) on the folder.

Works fine on Windows but in MacOS azure functions seems to think it should restart the language worker just after starting up, then conflict swith port 5858 which is already in use (by itself) and exits.

Some logging for funsies:

> [29/12/2019 08:56:11] Initializing function HTTP routes
> [29/12/2019 08:56:11] Mapped function route 'api/SearchIndex' [get,post] to 'SearchIndex'
> [29/12/2019 08:56:11] Mapped function route 'api/graphql' [get,post] to 'graphql'
> [29/12/2019 08:56:11]
> [29/12/2019 08:56:11] Host initialized (815ms)
> [29/12/2019 08:56:11] Host started (822ms)
> [29/12/2019 08:56:11] Job host started
> [29/12/2019 08:56:11] Debugger listening on ws://127.0.0.1:5858/e5cc9e96-b5b1-4406-8ceb-abe5a5be8eb9
> [29/12/2019 08:56:11] For help, see: https://nodejs.org/en/docs/inspector
> [29/12/2019 08:56:11] website
> Hosting environment: Production
> Content root path: /Users/ahmed/Documents/PrickKing/AzureTS
> Now listening on: http://0.0.0.0:7071
> Application started. Press Ctrl+C to shut down.
>
> Http Functions:
>
> SearchIndex: [GET,POST] http://localhost:7071/api/SearchIndex
>
> graphql: [GET,POST] http://localhost:7071/api/graphql
>
> [29/12/2019 08:56:12] DONE
> [7:56:12 PM] Found 0 errors. Watching for file changes.
>
**> [29/12/2019 08:56:13] Restarting host.** <-- lol wtf?
> [29/12/2019 08:56:13] Building host: startup suppressed: 'False', configuration suppressed: 'False', startup operation id: '8040deaa-7301-426b-a237-4da4bf54d33c'
> [29/12/2019 08:56:13] Reading host configuration file '/Users/ahmed/Documents/PrickKing/AzureTS/host.json'
> [29/12/2019 08:56:13] Host configuration file read:
> [29/12/2019 08:56:13] {
> [29/12/2019 08:56:13] "version": "2.0"
> [29/12/2019 08:56:13] }
> [29/12/2019 08:56:13] Reading functions metadata
> [29/12/2019 08:56:13] 2 functions found
> [29/12/2019 08:56:13] Initializing Warmup Extension.
> [29/12/2019 08:56:13] Initializing Host. OperationId: '8040deaa-7301-426b-a237-4da4bf54d33c'.
> [29/12/2019 08:56:13] Host initialization: ConsecutiveErrors=0, StartupCount=2, OperationId=8040deaa-7301-426b-a237-4da4bf54d33c
> [29/12/2019 08:56:13] LoggerFilterOptions
> [29/12/2019 08:56:13] {
> [29/12/2019 08:56:13] "MinLevel": "None",
> [29/12/2019 08:56:13] "Rules": [
> [29/12/2019 08:56:13] {
> [29/12/2019 08:56:13] "ProviderName": null,
> [29/12/2019 08:56:13] "CategoryName": null,
> [29/12/2019 08:56:13] "LogLevel": null,
> [29/12/2019 08:56:13] "Filter": "b__0"
> [29/12/2019 08:56:13] },
> [29/12/2019 08:56:13] {
> [29/12/2019 08:56:13] "ProviderName": "Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.SystemLoggerProvider",
> [29/12/2019 08:56:13] "CategoryName": null,
> [29/12/2019 08:56:13] "LogLevel": "None",
> [29/12/2019 08:56:13] "Filter": null
> [29/12/2019 08:56:13] },
> [29/12/2019 08:56:13] {
> [29/12/2019 08:56:13] "ProviderName": "Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.SystemLoggerProvider",
> [29/12/2019 08:56:13] "CategoryName": null,
> [29/12/2019 08:56:13] "LogLevel": null,
> [29/12/2019 08:56:13] "Filter": "b__0"
> [29/12/2019 08:56:13] }
> [29/12/2019 08:56:13] ]
> [29/12/2019 08:56:13] }
> [29/12/2019 08:56:13] FunctionResultAggregatorOptions
> [29/12/2019 08:56:13] {
> [29/12/2019 08:56:13] "BatchSize": 1000,
> [29/12/2019 08:56:13] "FlushTimeout": "00:00:30",
> [29/12/2019 08:56:13] "IsEnabled": true
> [29/12/2019 08:56:13] }
> [29/12/2019 08:56:13] SingletonOptions
> [29/12/2019 08:56:13] {
> [29/12/2019 08:56:13] "LockPeriod": "00:00:15",
> [29/12/2019 08:56:13] "ListenerLockPeriod": "00:00:15",
> [29/12/2019 08:56:13] "LockAcquisitionTimeout": "10675199.02:48:05.4775807",
> [29/12/2019 08:56:13] "LockAcquisitionPollingInterval": "00:00:05",
> [29/12/2019 08:56:13] "ListenerLockRecoveryPollingInterval": "00:01:00"
> [29/12/2019 08:56:13] }
> [29/12/2019 08:56:13] HttpOptions
> [29/12/2019 08:56:13] {
> [29/12/2019 08:56:13] "DynamicThrottlesEnabled": false,
> [29/12/2019 08:56:13] "MaxConcurrentRequests": -1,
> [29/12/2019 08:56:13] "MaxOutstandingRequests": -1,
> [29/12/2019 08:56:13] "RoutePrefix": "api"
> [29/12/2019 08:56:13] }
> [29/12/2019 08:56:13] Starting JobHost
> [29/12/2019 08:56:13] Starting Host (HostId=ahmedhakeemsmacbookpro-983144101, InstanceId=ffbb1ff6-01bb-4cd4-9549-dda4c0ff95a6, Version=2.0.12888.0, ProcessId=35570, AppDomainId=1, InDebugMode=False, InDiagnosticMode=False, FunctionsExtensionVersion=(null))
> [29/12/2019 08:56:13] Loading functions metadata
> [29/12/2019 08:56:13] 2 functions loaded
> [29/12/2019 08:56:13] Loading proxies metadata
> [29/12/2019 08:56:13] Initializing Azure Function proxies
> [29/12/2019 08:56:13] 0 proxies loaded
> [29/12/2019 08:56:13] Starting worker process:node --inspect=5858 "/Users/ahmed/.nvm/versions/node/v10.13.0/lib/node_modules/azure-functions-core-tools/bin/workers/node/dist/src/nodejsWorker.js" --host 127.0.0.1 --port 51551 --workerId a65acac8-d25a-4909-ad6d-cc12d83e9a56 --requestId 0edd6612-28fb-41b8-98ae-c4b098a1374d --grpcMaxMessageLength 134217728
> [29/12/2019 08:56:13] node process with Id=35598 started
> [29/12/2019 08:56:13] Generating 2 job function(s)
> [29/12/2019 08:56:13] Found the following functions:
> [29/12/2019 08:56:13] Host.Functions.SearchIndex
> [29/12/2019 08:56:13] Host.Functions.graphql
> [29/12/2019 08:56:13]
> [29/12/2019 08:56:13] Initializing function HTTP routes
> [29/12/2019 08:56:13] Mapped function route 'api/SearchIndex' [get,post] to 'SearchIndex'
> [29/12/2019 08:56:13] Mapped function route 'api/graphql' [get,post] to 'graphql'
> [29/12/2019 08:56:13]
> [29/12/2019 08:56:13] Host initialized (69ms)
> [29/12/2019 08:56:13] Host started (69ms)
> [29/12/2019 08:56:13] Job host started
**> [29/12/2019 08:56:13] Starting inspector on 127.0.0.1:5858 failed: address already in use** <-- because the host restarted for no reason?
> [29/12/2019 08:56:13] Starting worker process:node --inspect=5858 "/Users/ahmed/.nvm/versions/node/v10.13.0/lib/node_modules/azure-functions-core-tools/bin/workers/node/dist/src/nodejsWorker.js" --host 127.0.0.1 --port 51551 --workerId da826313-9c62-44ba-a29b-1db2d467df66 --requestId b91aba1b-50e0-44b9-a547-43b8afb33450 --grpcMaxMessageLength 134217728
> [29/12/2019 08:56:13] node process with Id=35599 started
> [29/12/2019 08:56:13] Starting inspector on 127.0.0.1:5858 failed: address already in use
> [29/12/2019 08:56:13] Starting worker process:node --inspect=5858 "/Users/ahmed/.nvm/versions/node/v10.13.0/lib/node_modules/azure-functions-core-tools/bin/workers/node/dist/src/nodejsWorker.js" --host 127.0.0.1 --port 51551 --workerId 224d821d-8be8-4d83-b346-79463e40d211 --requestId 12426c05-b598-45a4-84e6-a89fd057004c --grpcMaxMessageLength 134217728
> [29/12/2019 08:56:13] node process with Id=35600 started
> [29/12/2019 08:56:13] Starting inspector on 127.0.0.1:5858 failed: address already in use
> [29/12/2019 08:56:13] Exceeded language worker restart retry count for runtime:node. Shutting down Functions Host
> [29/12/2019 08:56:13] Stopping host...
> [29/12/2019 08:56:13] Stopping JobHost
> [29/12/2019 08:56:13] Job host stopped
> [29/12/2019 08:56:13] Host shutdown completed.

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue on macOS with `func host start --language-worker --inspect=5858` and a TypeScript `tsc -w` process, then compare the initial startup with the logged host restart. Start at the language worker launch shown in `azure-functions-core-tools/bin/workers/node/dist/src/nodejsWorker.js`; done means the host does not restart unexpectedly and the inspector port remains usable.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp, macos, node.js, typescript
Domain
backend, cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.