Azure / Azure/azure-functions-host
Value initialized outside of Run gets reset
- Dominant language
- C#
- Stars
- 2k
- Forks
- 482
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 36
Description
Please provide a succinct description of the issue.
#### Repro steps
Create an F# Timer function:
``` fsharp
open System
let epoch = DateTime(1970,1,1,0,0,0,DateTimeKind.Utc)
let Run(myTimer: TimerInfo, log: TraceWriter) =
log.Info(epoch.ToString())
```
#### Expected behavior
log should show the epoch as instantiated: `1/1/1970 12:00:00 AM`, in a fashion similar to what would be expected from a "regular" `.fsx` F# script.
#### Actual behavior
Function compiles and runs, but log show the epoch as `1/1/0001 12:00:00 AM`.
#### Known workarounds
- If I change the function to instantiate `epoch` inside the `Run` function, everything works as expected.
- If I modify the code to have epoch be the return value of another function like below, everything works fine:
``` fsharp
open System
let getEpoch () =
DateTime(1970,1,1,0,0,0,DateTimeKind.Utc)
let Run(myTimer: TimerInfo, log: TraceWriter) =
log.Info(getEpoch().ToString())
```
#### Related information
Provide any related information
* Programming language used : F#
* Links to source: source provided above.
Contributor guide
Research direction
Start by reproducing the supplied F# Timer function in the Azure Functions host and trace how the top-level epoch value is initialized before Run executes. No source file or test is named; done means the log preserves the initialized 1970 value without requiring initialization inside Run or through another function.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, fsharp
- Domain
- backend, cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100