Merge pull request #14021 from atom/as-fix-snapshot-stack-traces

Use the generated snapshot source map in `source-map-support`
This commit is contained in:
Antonio Scandurra
2017-03-17 18:05:42 +01:00
committed by GitHub
7 changed files with 19 additions and 9 deletions

View File

@@ -59,12 +59,12 @@ module.exports = function (packagedAppPath) {
relativePath == path.join('..', 'node_modules', 'tmp', 'lib', 'tmp.js')
)
}
}).then((snapshotScriptContent) => {
fs.writeFileSync(snapshotScriptPath, snapshotScriptContent)
}).then((snapshotScript) => {
fs.writeFileSync(snapshotScriptPath, snapshotScript)
process.stdout.write('\n')
console.log('Verifying if snapshot can be executed via `mksnapshot`')
vm.runInNewContext(snapshotScriptContent, undefined, {filename: snapshotScriptPath, displayErrors: true})
vm.runInNewContext(snapshotScript, undefined, {filename: snapshotScriptPath, displayErrors: true})
const generatedStartupBlobPath = path.join(CONFIG.buildOutputPath, 'snapshot_blob.bin')
console.log(`Generating startup blob at "${generatedStartupBlobPath}"`)

View File

@@ -9,7 +9,7 @@
"csslint": "1.0.2",
"donna": "1.0.13",
"electron-chromedriver": "~1.3",
"electron-link": "0.0.18",
"electron-link": "0.0.20",
"electron-mksnapshot": "~1.3",
"electron-packager": "7.3.0",
"electron-winstaller": "2.5.1",

View File

@@ -755,7 +755,10 @@ class AtomEnvironment extends Model
@lastUncaughtError = Array::slice.call(arguments)
[message, url, line, column, originalError] = @lastUncaughtError
{line, column} = mapSourcePosition({source: url, line, column})
{line, column, source} = mapSourcePosition({source: url, line, column})
if url is '<embedded>'
url = source
eventObject = {message, url, line, column, originalError}

View File

@@ -114,7 +114,7 @@ function writeCachedJavascript (relativeCachePath, code) {
var INLINE_SOURCE_MAP_REGEXP = /\/\/[#@]\s*sourceMappingURL=([^'"\n]+)\s*$/mg
exports.install = function (nodeRequire) {
exports.install = function (resourcesPath, nodeRequire) {
sourceMapSupport.install({
handleUncaughtExceptions: false,
@@ -122,6 +122,13 @@ exports.install = function (nodeRequire) {
// source-map-support module, but we've overridden it to read the javascript
// code from our cache directory.
retrieveSourceMap: function (filePath) {
if (filePath === '<embedded>') {
return {
map: snapshotResult.sourceMap, // eslint-disable-line no-undef
url: path.join(resourcesPath, 'app', 'static', 'index.js')
}
}
if (!cacheDirectory || !fs.isFileSync(filePath)) {
return null
}

View File

@@ -83,5 +83,5 @@ function handleStartupEventWithSquirrel () {
function setupCompileCache () {
const CompileCache = require('../compile-cache')
CompileCache.setAtomHomeDirectory(process.env.ATOM_HOME)
CompileCache.install(require)
CompileCache.install(process.resourcesPath, require)
}

View File

@@ -76,7 +76,7 @@ class Task
CompileCache = #{compileCacheRequire}
CompileCache.setCacheDirectory('#{compileCachePath}');
CompileCache.install(require)
CompileCache.install("#{process.resourcesPath}", require)
#{taskBootstrapRequire}
"""
bootstrap = bootstrap.replace(/\\/g, "\\\\")

View File

@@ -90,7 +90,7 @@
function setupWindow () {
const CompileCache = useSnapshot ? snapshotResult.customRequire('../src/compile-cache.js') : require('../src/compile-cache') // eslint-disable-line no-undef
CompileCache.setAtomHomeDirectory(process.env.ATOM_HOME)
CompileCache.install(require)
CompileCache.install(process.resourcesPath, require)
const ModuleCache = useSnapshot ? snapshotResult.customRequire('../src/module-cache.js') : require('../src/module-cache') // eslint-disable-line no-undef
ModuleCache.register(getWindowLoadSettings())