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

wrap injectScript call in try..catch, offer extension builds as PR artifacts #1520

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,50 @@ jobs:
- run: npm ci

# Build and output bunle stats to webpack-stats.json
- run: yarn build --env TARGET=chrome --json webpack-stats.json
- run: WEBPACK_BUILD_ARGS="--json webpack-stats.json" npm run dist:chrome

# Upload webpack-stats.json to use on relative-ci.yaml workflow
- name: Upload webpack stats artifact
uses: relative-ci/agent-upload-artifact-action@v2
with:
webpackStatsFile: ./webpack-stats.json

- uses: actions/upload-artifact@v4
id: chrome-artifact
with:
name: devtools-chrome
path: apollo-client-devtools-chrome.zip
retention-days: 14

# Build and output bunle stats to webpack-stats.json
- run: npm run dist:firefox

- uses: actions/upload-artifact@v4
id: firefox-artifact
with:
name: devtools-firefox
path: apollo-client-devtools-firefox.zip
retention-days: 14

- name: Output artifact URLs
run: echo "Artifact URLs are \n${{ steps.chrome-artifact.outputs.artifact-url }}\n and \n${{ steps.firefox-artifact.outputs.artifact-url }}\n"

- name: Find Comment
uses: peter-evans/find-comment@v3
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: "github-actions[bot]"
body-includes: <!-- ARTIFACT-DOWNLOAD -->

- name: Create comment
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
comment-id: ${{ steps.fc.outputs.comment-id }}
edit-mode: replace
body: |
<!-- ARTIFACT-DOWNLOAD -->
You can download the latest builds of the extension for this PR here:
* [Chrome](${{ steps.chrome-artifact.outputs.artifact-url }})
* [Firefox](${{ steps.firefox-artifact.outputs.artifact-url }})
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"start:dev": "run-p start:client start:server",
"dist:chrome": "npm run build -- --env TARGET=chrome && tsx build.ts chrome",
"dist:firefox": "npm run build -- --env TARGET=firefox && tsx build.ts firefox",
"build": "npm run clean && webpack --env NODE_ENV=production --progress",
"build": "npm run clean && webpack --env NODE_ENV=production --progress $WEBPACK_BUILD_ARGS",
"build:dev": "npm run clean && webpack --env NODE_ENV=development --progress",
"clean": "rimraf build && mkdir build && rimraf *.zip",
"changeset-publish": "npm run build -- --env TARGET=firefox && changeset publish",
Expand Down
9 changes: 8 additions & 1 deletion src/extension/tab/tab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,12 @@ if (__IS_FIREFOX__) {
}
}

injectScript(browser.runtime.getURL("hook.js"));
try {
injectScript(browser.runtime.getURL("hook.js"));
} catch (e) {
console.warn(
"Error occured while trying to initialize Apollo Client Devtools:",
e
);
}
Comment on lines +53 to +60
Copy link
Member Author

Choose a reason for hiding this comment

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

This doesn't work, as the error is triggered delayed when the script evaluates, not when it is inserted in DOM.

Also, listening for a securitypolicyviolation event allows me to read the details of the violation, but not to prevent it from crashing the whole page. I'm a bit out of ideas.

}