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

Issue #931 fix for not allowing caching #1050

Merged
merged 5 commits into from Aug 27, 2020
Merged

Issue #931 fix for not allowing caching #1050

merged 5 commits into from Aug 27, 2020

Conversation

dl748
Copy link
Contributor

@dl748 dl748 commented Jul 19, 2020

Fix for Issue #931 (I tested it out with the webpack plugin to verify)

Added module clear-module, to remove the module that the handler is in, from cache, from every request. Caching can be turned back on using "allowCache" = true in the configuration options

custom:
  serverless-offline:
    allowCache: true

I think the options should be passed to every runner, but it seems some options are nitpicked from the options and passed into the runners. I did the same for consistancy.

@lqueryvg
Copy link

Looks good !
What's needed to get this merged ?

@dl748
Copy link
Contributor Author

dl748 commented Jul 25, 2020

@dherault any issues with the PR?

@dherault
Copy link
Owner

@dl748 not at all, thanks for the PR, I'm taking a look

@dherault
Copy link
Owner

Looks good, maybe make it an option ?

@dl748
Copy link
Contributor Author

dl748 commented Jul 26, 2020

@dherault isn't it an option? Thats what allowCache: true does ?

@jacklp
Copy link

jacklp commented Jul 30, 2020

please can we have hot reloading so I can upgrade serverless-offline from 5.12

@lqueryvg
Copy link

@dherault it looks like this PR delivers an option which makes this configurable.
(As @dl748's last comment said.)
So can this be merged ?

Copy link

@stephledev stephledev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it's debatable if the default for allowCache should be true to align with the existing behaviour or false, so people don't have to actively opt-out (which the majority probably wants). Otherwise looks good.

@dl748
Copy link
Contributor Author

dl748 commented Aug 16, 2020

@stephledev I would think as a tool used mainly for developers, the default should be cache is off.

Copy link
Owner

@dherault dherault left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @dl748 ,
I like this PR that solves a big issue,
Can you please add some documentation and option help?
Thanks,

@dl748
Copy link
Contributor Author

dl748 commented Aug 26, 2020

@dherault Updated, unless you want more documentation and cli information than that.

@dherault dherault merged commit 787cfb0 into dherault:master Aug 27, 2020
@dherault
Copy link
Owner

Thanks! v6.7.0!

@dl748
Copy link
Contributor Author

dl748 commented Aug 27, 2020

@dherault this should fix issue #1027 as well, or any ticket involving cached code or hot reloading not working as this PR will uncache the require before reloading.

@jer-sen
Copy link

jer-sen commented Aug 28, 2020

@dl748 I face an error with allowCache: false when calling a lambda via an HTTP request: Failure: Cannot read property 'defineService' of undefined
No error with allowCache: true.
Any idea ?

@dl748
Copy link
Contributor Author

dl748 commented Aug 29, 2020

@jer-sen, i'd have to see your specific code, most likely you, or a package you are using is, using global variables.

@okarlsson
Copy link

@dl748 @dherault

This PR made my app start crashing when running with Serverless offline. Might be some combination with serverless-webpack.

Everything works when I set the allowCache flag to true

plugins:

plugins:
  - serverless-webpack
  - serverless-dynamodb-local
  - serverless-offline

Some of the stacktrace:

TypeError: argument must be an instance of Prompt
    at Array.addPrompt [as add] (/node_modules/oidc-provider/lib/helpers/interaction_policy/index.js:34:13)
    at base (/node_modules/oidc-provider/lib/helpers/interaction_policy/index.js:40:11)
    at getDefaults (/node_modules/oidc-provider/lib/helpers/defaults.js:2214:15)
    at Object.<anonymous> (/node_modules/oidc-provider/lib/helpers/request.js:6:46)

@jer-sen
Copy link

jer-sen commented Aug 31, 2020

@dl748 yes I'm using Apollo Server and a MongoDB persistent connection with callbackWaitsForEmptyEventLoop = false
Anything wrong ?

@raymond-w-ko
Copy link

I am also having issues with reloading.

If useCache: false then my node ClojureScript project crashes, but this can sort of be waved off being niche.

However, more importantly, this crashes any normal JS module with const AWS = require("aws-sdk") which makes development painful and negates the purpose.

Is there a way to prevent reloading stuff in a project's node_modules/* ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants