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

feat: add Java support for Functions debugging #3273

Merged
merged 5 commits into from
May 28, 2021

Conversation

rcoringrato-sfdc
Copy link
Contributor

What does this PR do?

  • Allow use of Debug Invoke feature for Java Functions

What issues does this PR fix or reference?

@W-9330349@

@rcoringrato-sfdc rcoringrato-sfdc requested a review from a team as a code owner May 27, 2021 16:37
@rcoringrato-sfdc rcoringrato-sfdc requested a review from xyc May 27, 2021 16:37
@@ -76,6 +76,9 @@ export class ForceFunctionStartExecutor extends SfdxCommandletExecutor<string> {
}

public execute(response: ContinueResponse<string>) {
const runtimeDetection: RegExp = new RegExp(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: upper case and move out of the class / make static since this is a constant

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also in the variable name describe we are detecting debug type here

@@ -143,7 +147,10 @@ export class ForceFunctionStartExecutor extends SfdxCommandletExecutor<string> {
);

execution.stdoutSubject.subscribe(data => {
if (data.toString().includes('Debugger running on port')) {
const matches = String(data).match(runtimeDetection);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious if this is the only option to find the function type? Any information about the language or the directory structure at the time of registering the function we could use instead?
I'm just trying to avoid the need to maintain a regex for any future changes in the output.

Copy link
Contributor Author

@rcoringrato-sfdc rcoringrato-sfdc May 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was my first approach, but I decided to change it. Since the build-pack is creating the environment seems like it is best suited to determine the runtime/debug settings.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, can we add an else condition for the line below where we check for matches and give a user warning that reads something like "Language could not be identified. 'Debug Invoke' may not work".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll see if I can move that type of logic to the 'Debug Invoke' - it should not be visible/enabled if the language hasn't been determined, or at least produce the warning you mentioned.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also looks like there is enough business logic now to add a separate section of tests in forceFunctionStart.test.ts

const matches = String(data).match(runtimeDetection);
if (matches && matches.length > 1) {
FunctionService.instance.updateFunction(functionDirPath, matches[1]);
} else if (data.toString().includes('Debugger running on port')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is here an else condition? Don't we want to close the notification irrespective of a language match or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The language match occurs fairly early, whereas the "running" message is one of the last messages.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Synced offline and now understand data is one line of stdout at a time. So, this is fine.

@rcoringrato-sfdc rcoringrato-sfdc merged commit 16e3806 into develop May 28, 2021
@rcoringrato-sfdc rcoringrato-sfdc deleted the rc/debug-invoke branch May 28, 2021 21:07
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.

3 participants