Title: Incorrectly parsing code · Issue #38 · stacktracejs/error-stack-parser · GitHub
Open Graph Title: Incorrectly parsing code · Issue #38 · stacktracejs/error-stack-parser
X Title: Incorrectly parsing code · Issue #38 · stacktracejs/error-stack-parser
Description: @tarr11 commented on Mon Jun 12 2017 I am using Function to parse and eval some code in the browser. I would like to use StackTraceJS to show errors to my users in the code editor. My code is minified using Webpack/Uglify, but user code ...
Open Graph Description: @tarr11 commented on Mon Jun 12 2017 I am using Function to parse and eval some code in the browser. I would like to use StackTraceJS to show errors to my users in the code editor. My code is minif...
X Description: @tarr11 commented on Mon Jun 12 2017 I am using Function to parse and eval some code in the browser. I would like to use StackTraceJS to show errors to my users in the code editor. My code is minif...
Opengraph URL: https://github.com/stacktracejs/error-stack-parser/issues/38
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Incorrectly parsing code","articleBody":"@tarr11 commented on [Mon Jun 12 2017](https://github.com/stacktracejs/stacktrace.js/issues/194)\n\n\u003c!--- Provide a general summary of the issue in the Title above --\u003e\r\nI am using `Function` to parse and eval some code in the browser. I would like to use StackTraceJS to show errors to my users in the code editor. My code is minified using Webpack/Uglify, but user code is not. User code is executed in a sandboxed iframe. \r\n\r\n## Expected Behavior\r\nI expect that StackFrameJS should parse \"anonymous\" errors correctly.\r\n\r\n## Current Behavior\r\nStackFrameJS does not parse anonymous errors like below, nor return the correct line number.\r\n\r\nSample User Code (should throw an error):\r\n\r\n\r\nMy code is executed like this\r\n```\r\n let runFunction = function (p) {\r\n let f = null;\r\n try {\r\n f = Function(\"p\", code)\r\n f(p);\r\n } catch (error) {\r\n StackTrace.fromError(error).then(sr =\u003e {\r\n window.parent.postMessage({sr, type: \"err\"}, \"*\");\r\n })\r\n\r\n }\r\n }\r\n // call runFunction\r\n runFunction(...);\r\n```\r\n\r\nThe stack trace looks like this (in Chrome)\r\n```\r\nReferenceError: hi is not defined\r\n at eval (eval at runFunction (http://localhost:8080/packs/iframe.js:5669:21), \u003canonymous\u003e:4:9)\r\n at runFunction (http://localhost:8080/packs/iframe.js:5670:17)\r\n at e.Sketch.sketch.attachFunction (http://localhost:8080/packs/iframe.js:5722:17)\r\n at e.Sketch.attach (eval at webpackJsonp.679.module.exports (http://localhost:8080/packs/iframe.js:11868:8), \u003canonymous\u003e:43:267)\r\n at Ir (eval at webpackJsonp.679.module.exports (http://localhost:8080/packs/iframe.js:11868:8), \u003canonymous\u003e:1417:89)\r\n at eval (eval at webpackJsonp.679.module.exports (http://localhost:8080/packs/iframe.js:11868:8), \u003canonymous\u003e:1415:106)\"\r\n```\r\n\r\nThe parsed stack trace looks like this (first line)\r\n\r\n\r\n\r\n\r\n## Steps to Reproduce (for bugs)\r\n\r\n## Context\r\n\u003c!--- How has this issue affected you? What are you trying to accomplish? --\u003e\r\nI am trying to use StackTrace to parse and show JS errors to a user in a browser editor (Monaco)\r\n\r\n## Your Environment\r\n\u003c!--- Include as many relevant details about the environment you experienced the bug in --\u003e\r\n* stacktrace.js version: 2.0\r\n* Browser Name and version: Chrome 58\r\n* Operating System and version (desktop or mobile): OS X Sierra 10.12.5\r\n\r\n\r\n## Possible Solution\r\nSuggest improving the parser to handle nested / anonymous stack traces\r\n\n\n---\n\n@eriwen commented on [Sat Aug 12 2017](https://github.com/stacktracejs/stacktrace.js/issues/194#issuecomment-322003767)\n\nThanks for the issue. Error parsing is done in `error-stack-parser`, so I'm moving the issue to that project.\n\n","author":{"url":"https://github.com/eriwen","@type":"Person","name":"eriwen"},"datePublished":"2017-08-12T20:24:18.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/38/error-stack-parser/issues/38"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:cb7e5653-0a74-bfd1-1766-857529e3c660 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D770:25678D:1217585:1939D6A:696F46A4 |
| html-safe-nonce | 6607f8b38748b20722799066d3ec3958175559037bfb4ec9ecc87608147b2170 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENzcwOjI1Njc4RDoxMjE3NTg1OjE5MzlENkE6Njk2RjQ2QTQiLCJ2aXNpdG9yX2lkIjoiNTUxMzExMDY4MTA4NDE4NDIyOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 9c98248e18d905ce00a644179ffe6c9f5470dd3bfb4891344f020dc6c1b35377 |
| hovercard-subject-tag | issue:249833471 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/stacktracejs/error-stack-parser/38/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5cc68ed0cb43e2fee052db9876f7b6723a6b7ee68d793f2e430b348a52246e89/stacktracejs/error-stack-parser/issues/38 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5cc68ed0cb43e2fee052db9876f7b6723a6b7ee68d793f2e430b348a52246e89/stacktracejs/error-stack-parser/issues/38 |
| og:image:alt | @tarr11 commented on Mon Jun 12 2017 I am using Function to parse and eval some code in the browser. I would like to use StackTraceJS to show errors to my users in the code editor. My code is minif... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | eriwen |
| hostname | github.com |
| expected-hostname | github.com |
| None | b278ad162d35332b6de714dfb005de04386c4d92df6475522bef910f491a35ee |
| turbo-cache-control | no-preview |
| go-import | github.com/stacktracejs/error-stack-parser git https://github.com/stacktracejs/error-stack-parser.git |
| octolytics-dimension-user_id | 6131251 |
| octolytics-dimension-user_login | stacktracejs |
| octolytics-dimension-repository_id | 15014773 |
| octolytics-dimension-repository_nwo | stacktracejs/error-stack-parser |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 15014773 |
| octolytics-dimension-repository_network_root_nwo | stacktracejs/error-stack-parser |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 39aed5006635ab6f45e6b77d23e73b08a00272a3 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width