Skip to content

Issue 52908: Ignore webpack:// source paths in mothership.js #6605

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

Merged
merged 1 commit into from
Apr 24, 2025
Merged
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
25 changes: 17 additions & 8 deletions core/webapp/mothership.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,20 +143,29 @@ LABKEY.Mothership = (function () {
// matches: ?_dc=12345 or ?12345
var _defeatCacheRegex = /\?(_dc=)?\d+/;

// Issue 52908: Ignore webpack:// source paths
// Workaround suggested here https://github.com/stacktracejs/stacktrace-gps/issues/65
function filterRequest(location, opts) {
if (location.includes('webpack://')) return '';
return fetch(location, opts).then((res) => res.status === 200 ? res.text() : '');
}

// Remove stacktrace.js and mothership.js from the stack
const fileNameFilters = ['/stacktrace.min.js', '/mothership.js'];

function filterTrace(stackframe) {
"use strict";

var fileName = stackframe.getFileName();
const fileName = stackframe.getFileName();

// remove stack elements for errors generated from within the Chrome console
if (!fileName)
if (!fileName) {
return false;
}

// remove stacktrace.js and mothership.js from the stack
if (_filterStacktrace &&
fileName.indexOf("/stacktrace.min.js") > -1 ||
fileName.indexOf("/mothership.js") != -1)
if (_filterStacktrace && fileNameFilters.some(s => fileName.includes(s))) {
return false;
}

// remove defeat cache and server-session number from URLs
// so stack doesn't change between server requests.
Expand Down Expand Up @@ -383,10 +392,10 @@ LABKEY.Mothership = (function () {

if (window.Promise) {
if (error instanceof Error) {
promise = StackTrace.fromError(error, {filter: filterTrace});
promise = StackTrace.fromError(error, { ajax: filterRequest, filter: filterTrace });
}
else if (_generateStacktrace) {
promise = StackTrace.get({filter: filterTrace});
promise = StackTrace.get({ ajax: filterRequest, filter: filterTrace });
}
}

Expand Down