Azure / Azure/azure-functions-host

Hot Reload not working when Typescript Function is in subdirectory

Open
#7,795 4 comments 2 reactions 0 assignees View on GitHub
needs-investigation stack: node-js
Dominant language
C#
Stars
2k
Forks
482
Avg merge
2d 12h
Merged PRs (30d)
38

Description

The hot reloading is not working when a Typescript function is in a subdirectory and you're using one of the following ways to start it:
```
func start --prefix {dir}
func start--script-root {dir}
cd {dir} && func start
```

# Repro
I made a reproduction repository with which I can reliably reproduce this issue: https://github.com/panmau/azure-function-hot-reload-repro

- Get the function running locally
- `curl http://localhost:7071/api/Test`
- Observe the logged output
- Make a change, for example: Hello World to Hello Universe
- Rerun `curl http://localhost:7071/api/Test`
- The logging output doesn't change! The compiled js file did. The function doesn't seem to restart after the recompilation.

The repro is based on the normal configuration that you receive with:
```
func init
func new
```
The difference is that I moved the directory of the function one level down, added one of the ways to start the function to package.json and updated the @azure/function package.

# Environment
```
func --version
3.0.3568

OS
Manjaro Linux 21.0.7 Ornara
```

Let me know whether you need any more info and if you can reproduce it.
I am willing to contribute the bugfix but I need some guidance in which area it could possibly be.

Contributor guide

Open the contributing guide

Research direction

Start with the linked reproduction repository and verify the failure using each of the three startup forms: --prefix, --script-root, and cd into the directory. Trace the host's hot-reload behavior for a TypeScript function in a subdirectory, then confirm that changing the source causes the next curl request to show the updated output in all affected configurations.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, typescript
Domain
backend, developer-experience
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.