Skip to content

Conversation

@StasD
Copy link
Contributor

@StasD StasD commented Oct 4, 2019

Summary:

Fixes #762

Test Plan:

Copy link
Member

@thymikee thymikee left a comment

Choose a reason for hiding this comment

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

Code LGTM, but haven't tested yet. Can you please update the PR description?
@Taym95 can you verify this works for you as well? :)

@StasD StasD changed the title Fix launchDebugger.js behaviour on macOS Fix buggy behaviour in launchDebugger.js on macOS Oct 4, 2019
logger.error('Google Chrome exited with error:', err);
}
});
return open(url, {app: [getChromeAppName()], wait: true});
Copy link
Contributor

@Taym95 Taym95 Oct 4, 2019

Choose a reason for hiding this comment

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

Test it, It's not working properly, still getting For a better debugging experience please install Google Chrome from.

I don't think we need to use wait: true here, from open documentation:

wait
Type: boolean

Wait for the opened app to exit before fulfilling the promise.
If false it's fulfilled immediately when opening the app.

I think we need to use async/await with open, something like this?

async function launchChrome(url: string) {
  const {err} = await open(url, {app: getChromeAppName()});
  if (err) {
    logger.error('Google Chrome exited with error:', err);
  }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without wait: true, it will not work as we need it to: no errors will be reported to the calling code and try/catch will not make any difference. Here is an extract from open's code:

	const subprocess = childProcess.spawn(command, cliArguments, childProcessOptions);

	if (options.wait) {
		return new Promise((resolve, reject) => {
			subprocess.once('error', reject);

			subprocess.once('close', exitCode => {
				if (exitCode > 0) {
					reject(new Error(`Exited with code ${exitCode}`));
					return;
				}

				resolve(subprocess);
			});
		});
	}

	subprocess.unref();

	return subprocess;

It seems to be working well with my modifications for me . :)

Copy link
Contributor

@Taym95 Taym95 Oct 4, 2019

Choose a reason for hiding this comment

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

Ah sorry my bad, tested it again works great!

@thymikee thymikee changed the title Fix buggy behaviour in launchDebugger.js on macOS fix: buggy behaviour when launching debugger on macOS Oct 5, 2019
@thymikee thymikee merged commit 743c466 into react-native-community:master Oct 5, 2019
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.

Buggy behaviour in launchDebugger.js on macOS

3 participants