Skip to content

Commit 6960373

Browse files
authored
fix: gracefully handle browser open failures (#178)
* fix: gracefully handle browser open failures * Update changelog
1 parent e4630b3 commit 6960373

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
### Fixed
9+
- Improved error handling when opening browser fails due to System Events permissions or non-standard browser configurations ([#178](https://github.com/MetaMask/create-release-branch/pull/178))
10+
- Now provides clear manual URL instructions instead of failing with osascript errors
11+
- Handles both cases: when terminal lacks System Events permissions and when using alternative browsers like Brave
812

913
## [4.1.1]
1014
### Fixed

src/main.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ export async function main({
4242
);
4343

4444
if (interactive) {
45-
stdout.write(`Starting UI on port ${port}...\n`);
4645
await startUI({
4746
project,
4847
releaseType,

src/ui.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { WriteStream } from 'fs';
22
import { join } from 'path';
33
import express from 'express';
4-
import open, { apps } from 'open';
4+
import open from 'open';
55

66
import {
77
restoreChangelogsForSkippedPackages,
@@ -86,8 +86,18 @@ export async function startUI({
8686

8787
const server = app.listen(port, async () => {
8888
const url = `http://localhost:${port}`;
89-
stdout.write(`UI server running at ${url}\n`);
90-
open(url, { app: { name: apps.browser } });
89+
90+
try {
91+
stdout.write(`\nAttempting to open UI in browser...`);
92+
await open(url);
93+
stdout.write(`\nUI server running at ${url}\n`);
94+
} catch (error) {
95+
stderr.write(`\n---------------------------------------------------\n`);
96+
stderr.write(`Error automatically opening browser: ${error}\n`);
97+
stderr.write(`Please open the following URL manually:\n`);
98+
stderr.write(`${url}\n`);
99+
stderr.write(`---------------------------------------------------\n\n`);
100+
}
91101
});
92102

93103
return new Promise((resolve, reject) => {

0 commit comments

Comments
 (0)