-
Notifications
You must be signed in to change notification settings - Fork 59
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
Assign data in onPreResponse lifecycle extension with takeover #144
Comments
What is happening first, yar registration or your custom onPreResponse ext setup? |
They are both plugins included in the same array, but const plugins = [
// other plugins
{
plugin: require('yar'),
options: {
name: nconf.get('redis:cookieName'),
maxCookieSize: 0,
cache: {
expiresIn: nconf.get('redis:ttl')
},
cookieOptions: {
ttl: nconf.get('redis:ttl'),
password: nconf.get('redis:secret'),
isSecure:
process.env.NODE_ENV === 'production' ||
process.env.NODE_ENV === 'staging' ||
process.env.NODE_ENV === 'ephemeral',
isHttpOnly:
process.env.NODE_ENV === 'production' ||
process.env.NODE_ENV === 'staging' ||
process.env.NODE_ENV === 'ephemeral'
},
storeBlank: false
}
},
// other plugins
{ plugin: require('./routes/main') },
// other plugins
];
await server.register(plugins)
|
onPreResponse
lifecycle?
You need to call the new |
Is this a new feature that's not available in [email protected]? |
Only in 10.1.0. |
Support plan
Context
How can we help?
Hi! I'm fairly new to
yar
andhapi
, but let me do my best to explain what I'm trying to accomplish:keepAlive
agent on these calls, but the challenge we are facing now is every once in a while the service closes the connection and responds withECONNRESET
error.ECONNRESET
errors, redirect to homepage, and show a simple alert.ECONNRESET
response on theonPreResponse
lifecycle, (b) set an alert message in session, and (c) change the response to a redirect to homepage. Here's the snippet:But for some reason, the
alerts
in session did not persist fromonPreResponse
to the homepage pre-handler, i.e.,request.yar.get('alerts') === null
in the pre-handler. Is there something aboutonPreResponse
lifecycle that doesn't allow me to save data into session? Any help is greatly appreciated.Below are my
yar
options. I tried to distill the code snippets to just the relevant parts, but let me know if I can provide any further info that might help.Many thanks!
The text was updated successfully, but these errors were encountered: