-
Notifications
You must be signed in to change notification settings - Fork 365
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: support for Edge Functions debugging #4615
Conversation
📊 Benchmark resultsComparing with 64fca17 Package size: 287 MB(no change)
Legend
|
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.
Left a few comments, but looking great generally! ✨
src/commands/dev/dev.js
Outdated
new Option( | ||
'-E, --edgeInspectBrk [inspectHostPort]', | ||
'enable Deno inspect-brk with optional inspectHostPort', | ||
).conflicts('edgeInspect'), |
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.
Nice use of .conflicts()
! ✨
src/commands/dev/dev.js
Outdated
const getAddress = () => { | ||
if (edgeInspect) { | ||
// .slice(1) to remove the = in `=127.0.0.1:9229` | ||
return typeof edgeInspect === 'string' ? edgeInspect.slice(1) : undefined |
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'm confused as to why you need to slice this. Commander is supposed to handle this automatically for you.
I've just pulled your branch, tried using ntl dev --edgeInspect=127.0.0.1:1234
and ntl dev --edgeInspect 127.0.0.1:1234
and in both cases options.edgeInspect
has the right contents, with no need to slice.
Am I missing something?
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.
Aha, this was because I was (wrongfully) using the short form that doesn't support the equal sign ending up with edgeInspect: '=127.0.0.1:3030'
if ntl dev -e=127.0.0.1:1234
is used.
I've updated the help flag with more examples on how to use the short forms:
'netlify dev -e 127.0.0.1:9229',
'netlify dev -e127.0.0.1:9229',
'netlify dev -E 127.0.0.1:9229',
'netlify dev -E127.0.0.1:9229',
I don't know if this is sufficient though because the error that pops up when -e=127.0.0.1:1234
or -E=127.0.0.1:1234
is ran is what's below from deno. The --help
flag suggestion will bring up the above examples though when ran with netlify dev
. 🤔
error: Invalid value for '--inspect=<HOST:PORT>...': invalid IP address syntax
For more information try --help
Caused by:
invalid IP address syntax
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.
@eduardoboucas this one is updated and ready
Co-authored-by: Eduardo Bouças <mail@eduardoboucas.com>
Co-authored-by: Eduardo Bouças <mail@eduardoboucas.com>
Co-authored-by: Eduardo Bouças <mail@eduardoboucas.com>
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.
Great work! Left a minor, non-blocking comment.
src/commands/dev/dev.js
Outdated
'netlify dev -e', | ||
'netlify dev -e 127.0.0.1:9229', | ||
'netlify dev -e127.0.0.1:9229', | ||
'netlify dev --edgeInspect', | ||
'netlify dev --edgeInspect=127.0.0.1:9229', | ||
'netlify dev -E', | ||
'netlify dev -E 127.0.0.1:9229', | ||
'netlify dev -E127.0.0.1:9229', | ||
'netlify dev --edgeInspectBrk', | ||
'netlify dev --edgeInspectBrk=127.0.0.1:9229', |
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.
[dust] I don't think we need to add an example for every single permutation, otherwise we'll end up with a huge list in the help command. How do you feel about keeping just the ones below?
'netlify dev -e', | |
'netlify dev -e 127.0.0.1:9229', | |
'netlify dev -e127.0.0.1:9229', | |
'netlify dev --edgeInspect', | |
'netlify dev --edgeInspect=127.0.0.1:9229', | |
'netlify dev -E', | |
'netlify dev -E 127.0.0.1:9229', | |
'netlify dev -E127.0.0.1:9229', | |
'netlify dev --edgeInspectBrk', | |
'netlify dev --edgeInspectBrk=127.0.0.1:9229', | |
'netlify dev --edgeInspect', | |
'netlify dev --edgeInspect=127.0.0.1:9229', | |
'netlify dev --edgeInspectBrk', | |
'netlify dev --edgeInspectBrk=127.0.0.1:9229', |
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 added the short form ones just in case someone uses the =
sign with -e
or -E
and it fails, they see an example of how go use them with the --help
flag. This is because something like -e=127.0.0.1:1234
gives us edgeInspect: '=127.0.0.1:3030'
because short forms don't support the equal sign causing it to fail.
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 understand that, but you could make the same argument for every single parameter we have. The noise of adding every permutation to the help command will make the help command less useful, IMO.
If we're worried that people will misuse the command and get confused about the TypeError: Invalid URL
error message (which I agree is not very helpful), we should consider adding validation to the input, so that we throw an error if it's not a valid host/port pair.
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.
You can do this by specifying a custom parser. See https://github.com/tj/commander.js/#custom-option-processing.
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.
@eduardoboucas this is now done, the review also got reset.
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.
Great work! 🚀
@@ -27,6 +27,7 @@ const { | |||
readGraphQLOperationsSourceFile, | |||
} = require('../../lib/one-graph/cli-netlify-graph') | |||
const { | |||
BANG, |
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.
💥
Co-authored-by: Eduardo Bouças <mail@eduardoboucas.com>
🎉 Thanks for submitting a pull request! 🎉
Summary
Fixes https://github.com/netlify/pillar-runtime/issues/357
Dependent on: netlify/edge-bundler#31
This PR adds flags to run with
netlify dev
to extenddeno --inspect
anddeno --inspect-brk
for Edge Functions debugging. The--edgeInspect
and--edgeInspectBrk
have the-e
and-E
flags respectively as aliases. Each can take a custom host and port that defaults to the default HOST:PORT if none is specified.To test this out, clone
feat/debug-edge-functions-flags
branch of edge-bundler; runnpm install
andnpm run build
in edge-bundler to set it up; edit CLI package.json to use the cloned version of edge-bundler eg"@netlify/edge-bundler": "file:../edge-bundler"
and run some of the below examples in an Edge Functions project.Examples:
For us to review and ship your PR efficiently, please perform the following steps:
passes our tests.
A picture of a cute animal (not mandatory, but encouraged)