diff --git a/app/client/cypress/e2e/Regression/ClientSide/OtherUIFeatures/Logs2_spec.js b/app/client/cypress/e2e/Regression/ClientSide/OtherUIFeatures/Logs2_spec.js index e4f9b5369c..479f76bee3 100644 --- a/app/client/cypress/e2e/Regression/ClientSide/OtherUIFeatures/Logs2_spec.js +++ b/app/client/cypress/e2e/Regression/ClientSide/OtherUIFeatures/Logs2_spec.js @@ -291,4 +291,31 @@ describe("Debugger logs", function () { cy.get(".t--js-action-name-edit-field").should("exist"); }); + + it("10. Bug #24039 - Logs errors from setInterval callback into debugger", () => { + _.entityExplorer.NavigateToSwitcher("Widgets"); + _.entityExplorer.DragDropWidgetNVerify("buttonwidget", 400, 600); + _.entityExplorer.SelectEntityByName("Button1", "Widgets"); + _.propPane.SelectPlatformFunction("onClick", "Set interval"); + _.agHelper.EnterActionValue( + "Callback function", + `{{() => { + try { + Test.run(); + } catch (e) { + clearInterval('myInterval'); + throw e; + } + } + }}`, + ); + _.agHelper.EnterActionValue("Id", "myInterval"); + _.agHelper.Sleep(); + _.agHelper.GetNClick(_.jsEditor._logsTab); + _.debuggerHelper.ClearLogs(); + _.agHelper.ClickButton("Submit"); + _.debuggerHelper.DoesConsoleLogExist( + "Uncaught ReferenceError: Test is not defined", + ); + }); }); diff --git a/app/client/src/workers/Evaluation/evaluation.worker.ts b/app/client/src/workers/Evaluation/evaluation.worker.ts index 53c3795d40..dc157e392a 100644 --- a/app/client/src/workers/Evaluation/evaluation.worker.ts +++ b/app/client/src/workers/Evaluation/evaluation.worker.ts @@ -44,6 +44,14 @@ async function asyncRequestMessageListener( self.addEventListener("message", syncRequestMessageListener); self.addEventListener("message", asyncRequestMessageListener); +self.addEventListener("error", (e) => { + if (e instanceof ErrorEvent) { + console.error(e.message); + } else { + console.error(e); + } +}); + self.addEventListener("unhandledrejection", (e) => { // We might want to send this error to the main thread in the future. // console error will log the error to the logs tab against trigger field.