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
feat: request and reply decorators can not be a reference type #5462
Conversation
lib/decorate.js
Outdated
if (typeof fn === 'object' && fn && !(typeof fn.getter === 'function' || typeof fn.setter === 'function')) { | ||
FSTDEP006(name) | ||
return encapsulatedDecorator(fn) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would just throw in this case and not clone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So are we removing the warning to replace it with an error while suggesting the user use the getter/setter interface?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code lgtm
Can you update the PR title and description?
Implements #2598
This PR replaces the WARN message with an error when a reference type is used as a request or reply decorator, suggesting using a different API.
To use a reference type as a decorator without sharing values across requests, the user must use the
getter/setter
interface or thehook
approach. Both methods are documented with examples.This PR has been sponsored by Nearform
Checklist
npm run test
andnpm run benchmark
and the Code of conduct