question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Guidance needed - how to store request context?

See original GitHub issue

Hi @goatslacker!

So I have a logger set up inside an express middleware, logging various things about the request.

One bit of information I’d like to add to the logs is - did the request hit a cold cache or not?

I have access to this information inside of my application code - inside of getComponent. However there’s no great way that I can currently think of to thread this information along to other parts of the express app.

I’m thinking one way to do this would be to expose the express request object to the context object passed into getComponent https://github.com/airbnb/hypernova/blob/477257daad82e04f24ce851a9b3d21625354c783/src/utils/BatchManager.js#L90

Or maybe there’s just a better way to architect this?

Thanks!

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
goatslackercommented, Mar 14, 2018

Why don’t we pass a reference to res.locals?

1reaction
ljharbcommented, Mar 14, 2018

I usually stick things on the response object (and never mutate the request)

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Request Context — Flask Documentation (2.2.x)
The request context keeps track of the request-level data during a request. Rather than passing the request object to each function that runs...
Read more >
Understanding the Application and Request Contexts in ...
This post provides clarity on how the Application and Request contexts work in Flask.
Read more >
Store Custom Data in Spring MVC Request Context
Store Custom Data in Spring MVC Request Context · Use HttpServletRequest or WebRequest · Annotate context bean with @RequestScope.
Read more >
Context Management
Bound contexts are attached to some external data store (such as the HTTP Session or a manually propagated map) by associating the data...
Read more >
Context | Android Developers
Return a new Context object for the current Context but whose storage APIs ... Retrieve, creating if needed, a new directory in which...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found