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

Handler is not updated #42

Open
zigzhang opened this issue Jun 29, 2018 · 5 comments
Open

Handler is not updated #42

zigzhang opened this issue Jun 29, 2018 · 5 comments
Assignees

Comments

@zigzhang
Copy link

zigzhang commented Jun 29, 2018

Hi,

Problem:
After starting serverless offline serverless offline start, I can publish a message on SNS offline without any problem, and the handler is running.
When I change the code in my handler and publish again a message, the previous handler is run, and not the updated one.

I need to stop serverless offline and re-start it for the changes to be taken into account.

Why it matters:
For debug purposes, it'd be great to be able to change the handler test without having to re-start serverless offline every time.

Version: node 8.10

    "serverless": "^1.26.1",
    "serverless-offline": "^3.20.3",
    "serverless-offline-sns": "^0.42.0",

Thanks!

@mj1618
Copy link
Owner

mj1618 commented Jul 29, 2019

I'll look into this at some point, I can see it is inconvenient. Not sure how to solve it yet. It may be that we need this function to change to be called on every invocation rather than just once -
https://github.com/mj1618/serverless-offline-sns/blob/master/src/index.ts#L201

@mj1618 mj1618 closed this as completed in 94cd3c0 Jul 29, 2019
mj1618 added a commit that referenced this issue Jul 29, 2019
@frostyseb
Copy link

frostyseb commented Nov 29, 2023

Hi, the function handler is still not updated to the latest. I am using the following versions:
Node: 16.20.0

"serverless": "^3.36.0",
"serverless-offline": "^13.2.0",
"serverless-offline-sns": "^0.77.2"

@dsarlo
Copy link
Collaborator

dsarlo commented Nov 29, 2023

Thanks for the report @frostyseb. I will reopen this and will look into it at some point

@dsarlo dsarlo reopened this Nov 29, 2023
@dsarlo dsarlo self-assigned this Nov 29, 2023
@dsarlo
Copy link
Collaborator

dsarlo commented Dec 2, 2023

@frostyseb A little update here. Did some testing and I came to the conclusion that 1) the handler needs to be re-imported on each invocation not just when we subscribe to the sns topic on initialization (as mentioned above) and 2) we need to be able to invalidate the node module cache.

Sadly, 2 is not currently possible which is why I initially removed cache invalidation as a parameter in version 0.77.0

See: nodejs/node#49442 - tracking esm cache busting

Once there is a solution available, I will resolve this issue. I have a branch ready to go. I was able to get this to work properly with a non-esm project using createRequire and deleting the module from the cache on each re-import but this does not work for esm projects, so for compatibility purposes, we will wait and see what the node team comes up with.

@frostyseb
Copy link

Hi @dsarlo , thank you very much for the update! I really appreciate your effort in this enhancement. Understandable on the esm cache busting issue and compatibility. We shall see how the node team will improve this.

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

No branches or pull requests

4 participants