Skip to content

Commit

Permalink
Release v1.1.2
Browse files Browse the repository at this point in the history
- Upgrade build dependencies
- Ignore tab closed error on chrome >=102
- Ignore errors on special pages
  • Loading branch information
nmasnadithya committed Aug 5, 2022
1 parent 5b4903f commit 6214bca
Show file tree
Hide file tree
Showing 5 changed files with 1,363 additions and 1,113 deletions.
7 changes: 6 additions & 1 deletion background/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ class PageProcessor {
}

handleError = (err) => {
if (this.url.startsWith('https://ntp.msn.com')) {
// TODO: Handle the New Tab Page(NTP) in Edge and
// remove this when adding official Edge support
LOGGER.error('Ignoring Edge Errors', err)
return
}
submitError({
data: err.message,
tab: this.tabId,
Expand Down Expand Up @@ -200,7 +206,6 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
}, err, err.stack).then()
sendResponse(`failed ${message['paperId']}`)
}
return true
})

chrome.runtime.onConnect.addListener(function(port) {
Expand Down
37 changes: 23 additions & 14 deletions common/error.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
import {ajaxCall} from './utils'
import {LOGGER} from "./logger";
import {LOGGER} from './logger'

const EXCLUDED_ERRORS = [
// When extension is allowed on all sites and the extension tries to run on special pages such as new tab
'Extension manifest must request permission to access this host.',
'Extension manifest must request permission to access the respective host.',
'Cannot access a chrome:// URL',
// When extension is allowed on all sites and the extension tries to run on chrome store
'The extensions gallery cannot be scripted.',
// When the tab is closed before the backend responds to the links
'A listener indicated an asynchronous response by returning true, but the message channel closed before a response was received.',
]

export async function submitError(
data: Object,
event: any,
stackTrace?: any
data: Object,
event: any,
stackTrace?: any,
): Promise<any> {
LOGGER.error(data, event, stackTrace)
let e = event.hasOwnProperty('reason') ? event.reason : event
Expand All @@ -31,19 +42,17 @@ export async function submitError(
} catch (e) {
}
let jsonData = JSON.stringify(msg, null, '\t')
if (
jsonData.includes(
'Extension manifest must request permission to access this host.'
) ||
jsonData.includes('The extensions gallery cannot be scripted.')
) {
return {}
for (let errorMsg of EXCLUDED_ERRORS) {
if (jsonData.includes(errorMsg)) {
LOGGER.error('Ignoring excluded error', jsonData)
return {}
}
}
try {
let res: any = await ajaxCall(
'POST',
`https://papers.labml.ai/api/v1/error`,
{error: jsonData}
'POST',
`https://papers.labml.ai/api/v1/error`,
{error: jsonData},
)
return res
} catch (e) {
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"48": "assets/icon48.png",
"128": "assets/icon128.png"
},
"version": "1.1.1",
"version": "1.1.2",
"description": "\uD83D\uDD0E View information about research papers linked from websites you visit.",
"background": {
"service_worker": "js/background.js"
Expand Down
Loading

0 comments on commit 6214bca

Please sign in to comment.