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

Add hook names #94

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

Conversation

kibertoad
Copy link
Contributor

This provides readable names for hook invocations in stacktraces and observability tools like New Relic.

@kibertoad
Copy link
Contributor Author

kibertoad commented Nov 27, 2023

@SkeLLLa None of the CI errors seem to relate to changes in the PR. Do builds work on main OK?

@kibertoad
Copy link
Contributor Author

Update: #95 is passing, so this is something that I broke. Will check.

@kibertoad kibertoad marked this pull request as draft November 27, 2023 16:21
@SkeLLLa
Copy link
Owner

SkeLLLa commented Nov 27, 2023

Yeah, failing check look weird. Maybe there's some this binding is lost during the transition from arrow functions to plain functions.

Maybe as workaround you could try just named arrow functions like const onSomething = () => { ... }

@kibertoad kibertoad marked this pull request as ready for review November 27, 2023 16:33
@kibertoad
Copy link
Contributor Author

sure, if current version doesn't work, will use named arrow functions!

@kibertoad kibertoad marked this pull request as draft November 27, 2023 16:34
@@ -133,7 +133,7 @@
return;
}

this.deps.fastify.addHook('onRoute', (routeOptions) => {
this.deps.fastify.addHook('onRoute', function onRouteMetrics(this: FastifyMetrics routeOptions) {

Check notice

Code scanning / CodeQL

Syntax error Note

Error: ',' expected.
@kibertoad
Copy link
Contributor Author

@SkeLLLa problem with const namedArrowFunction is that this approach requires making quite a few FastifyMetrics fields/methods to become public :-/. Wonder if there even exists a good solution here.

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

Successfully merging this pull request may close these issues.

2 participants