Skip to content

Instantly share code, notes, and snippets.

@taylorreece
Last active April 23, 2021 15:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taylorreece/70ed16b320da4fc398759dffa811620e to your computer and use it in GitHub Desktop.
Save taylorreece/70ed16b320da4fc398759dffa811620e to your computer and use it in GitHub Desktop.
Show that a Lambda reuses a "dirty" environment in subsequent requests.
// The first time this lambda is invoked, you will see a console message, "Hello, world!"
// If you invoke the lambda again soon thereafter, you will see "Your message has been hijacked"
// due to console.log being overridden from the first invocation.
exports.handler = async (event) => {
console.log("Hello, world!");
global.console.log = (msg) => {
console.error("Your message has been hijacked");
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment