dherault / dherault/serverless-offline

After code changes, old code is still used

Open
#1,659 11 comments 4 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
5.3k
Forks
811
Avg merge
2d 4h
Merged PRs (30d)
3

Description

## Bug Report

**Current Behavior**

I have a javascript/typescript project using serverless-offline. Previously after I made changes to a file and then made a call to a http endpoint, it would run the new code. After version 9 however, it's still running the old code. So I have to restart serverless-offline after every change I make, which of course makes development very slow.

**Sample Code**

https://github.com/trygveaa/serverless-offline-reload-bug

Steps to reproduce:
1. Run `npm run start` in that repo
2. Make a request to http://localhost:3000/dev/hello
3. Change the return body in `src/handler.js` to something else.
4. Make a new request to http://localhost:3000/dev/hello

It's important that you make the request in step 2, as it will pick up any changes done before the first request, but after one request is made, it will always run that code until it's restarted.

**Expected behavior/code**

When a request is made, the current code should always be run.

**Environment**

- `serverless` version: 3.27.0
- `serverless-offline` version: 12.0.4
- `node.js` version: 16.19.0
- `OS`: Arch Linux

**Additional context/Screenshots**

I bisected the issue and found that it was introduced in commit 78fec17b. As you can see from the repo, I'm not using the `allowCache` option that was removed there, so there must be some unintended side effects by that commit.

Contributor guide

Open the contributing guide

Research direction

Start with the linked reproduction repository and its src/handler.js, then inspect commit 78fec17b, which was identified as the regression point. Run npm run start and follow the request/change/request sequence to observe the cached behavior. Done means a second request runs the current code without restarting serverless-offline.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
api, backend, developer-experience
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.