噩梦在 Travis 上崩溃:`nightmare:log crashed [{},false]`
Nightmare crashing on Travis: `nightmare:log crashed [{},false]`
我在 Travis CI 上把这个发给 运行 真是太难了。它间歇性地工作,但噩梦经常因以下错误而失败:
nightmare:log did-get-response-details [{},false,"https://fonts.gstatic.com/s/roboto/v16/Hgo13k-tfSpn0qi1SFdUfVtXRa8TVwTICgirnJhmVJw.woff2","https://fonts.gstatic.com/s/roboto/v16/Hgo13k-tfSpn0qi1SFdUfVtXRa8TVwTICgirnJhmVJw.woff2",200,"GET","https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Material+Icons",{"accept-ranges":["bytes"],"access-control-allow-origin":["*"],"age":["706260"],"alt-svc":["quic=\":443\"; ma=2592000; v=\"37,36,35\""],"cache-control":["public, max-age=31536000"],"content-length":["14696"],"content-type":["font/woff2"],"date":["Mon, 17 Apr 2017 21:24:49 GMT"],"expires":["Tue, 17 Apr 2018 21:24:49 GMT"],"last-modified":["Tue, 04 Apr 2017 18:34:45 GMT"],"server":["sffe"],"status":["200"],"timing-allow-origin":["*"],"x-content-type-options":["nosniff"],"x-xss-protection":["1; mode=block"]},"other"] +0ms
nightmare:log did-stop-loading [{}] +276ms
nightmare:log crashed [{},false] +1ms
nightmare:actions .wait() for .main-container element or 1000msec +29s
nightmare:actions .evaluate() fn on the page +1s
/home/travis/build/esalter-va/esalter-va.github.io/node_modules/webpack-static-site-generator/render.js:30
setTimeout(function () {throw err})
^
Error: Evaluation timed out after 30000msec. Are you calling done() or resolving your promises?
at Timeout._onTimeout (/home/travis/build/esalter-va/esalter-va.github.io/node_modules/nightmare/lib/actions.js:509:10)
at ontimeout (timers.js:386:14)
at tryOnTimeout (timers.js:250:5)
at Timer.listOnTimeout (timers.js:214:5)
我正在尝试 运行 使用 Nightmare 的 Webpack 扩展。代码是here,但我的设置如下。
// plugin: index.js
if (process.platform === 'linux'){
xvfb.startSync()
process.env['DISPLAY'] = ':99.0'
}
var server = serve(self.outputPath)
var port = server.address().port
var outputFiles = render(port, self.routes, self.elementToWaitFor)
outputFiles.then(files => {
for (var i = 0; i < files.length; i++) {
var outputFilePath = path.join(self.outputPath, self.routes[i])
var outputFileName = path.join(outputFilePath, 'index.html')
fsPath.writeFile(outputFileName, files[i])
}
server.close(function () {
xvfb.stopSync()
done()
})
}).catch(err => {
setTimeout(function () {throw err})
server.close(function () {
xvfb.stopSync()
done()
})
})
// plugin: render.js (where `var outputFiles = render(port, self.routes, self.elementToWaitFor)` goes)
function render(port, routes, elementToWaitFor) {
var nightmare = Nightmare({
show: false,
webPreferences: {
partition: 'partition-' + Math.random()
}
})
var baseUrl = `http://localhost:${port}`
var pageContents = routes.reduce(function (accumulator, route) {
return accumulator.then(function (results) {
var url = baseUrl + route
return nightmare
.goto(url)
.wait(elementToWaitFor, 1000)
.evaluate(function () {
return document.documentElement.innerHTML
})
.then(function (content) {
results.push(content)
return results
})
.catch(err => {
setTimeout(function () {throw err})
})
})
}, Promise.resolve([]))
return pageContents.then(function (values) {
return nightmare.end().then(function () {
return values
})
}).catch(err => {
setTimeout(function () {console.log(`Error ${err}`)})
})
}
# .travis.yml (project that uses plugin)
language: node_js
node_js:
- "node"
addons:
apt:
packages:
- xvfb
- libxss1
script:
- yarn run lint
- yarn run build
// package.json
"scripts": {
"build": "DEBUG=nightmare:*,electron:* node build/build.js",
},
构建脚本 运行 是 Webpack,运行 是我的 Nightmare 脚本。 Here's a Gist with the full error log.
我已经尝试了所有可以在网上找到的解决方案,但似乎没有任何效果。
我尝试过的一些事情(我记得:
Nightmare({show: false})
Nightmare({webPreferences: {partition: 'partition-' + Math.random()}
- 为
.wait()
添加超时
- 根据不同的在线帖子建议添加更多
apt
包
- 一大堆其他的,应该写下来。
任何帮助将不胜感激,如果我遗漏了什么,请告诉我!
这似乎已通过将 sudo: required
添加到我的 .travis.yml
来解决。
我在 Travis CI 上把这个发给 运行 真是太难了。它间歇性地工作,但噩梦经常因以下错误而失败:
nightmare:log did-get-response-details [{},false,"https://fonts.gstatic.com/s/roboto/v16/Hgo13k-tfSpn0qi1SFdUfVtXRa8TVwTICgirnJhmVJw.woff2","https://fonts.gstatic.com/s/roboto/v16/Hgo13k-tfSpn0qi1SFdUfVtXRa8TVwTICgirnJhmVJw.woff2",200,"GET","https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Material+Icons",{"accept-ranges":["bytes"],"access-control-allow-origin":["*"],"age":["706260"],"alt-svc":["quic=\":443\"; ma=2592000; v=\"37,36,35\""],"cache-control":["public, max-age=31536000"],"content-length":["14696"],"content-type":["font/woff2"],"date":["Mon, 17 Apr 2017 21:24:49 GMT"],"expires":["Tue, 17 Apr 2018 21:24:49 GMT"],"last-modified":["Tue, 04 Apr 2017 18:34:45 GMT"],"server":["sffe"],"status":["200"],"timing-allow-origin":["*"],"x-content-type-options":["nosniff"],"x-xss-protection":["1; mode=block"]},"other"] +0ms
nightmare:log did-stop-loading [{}] +276ms
nightmare:log crashed [{},false] +1ms
nightmare:actions .wait() for .main-container element or 1000msec +29s
nightmare:actions .evaluate() fn on the page +1s
/home/travis/build/esalter-va/esalter-va.github.io/node_modules/webpack-static-site-generator/render.js:30
setTimeout(function () {throw err})
^
Error: Evaluation timed out after 30000msec. Are you calling done() or resolving your promises?
at Timeout._onTimeout (/home/travis/build/esalter-va/esalter-va.github.io/node_modules/nightmare/lib/actions.js:509:10)
at ontimeout (timers.js:386:14)
at tryOnTimeout (timers.js:250:5)
at Timer.listOnTimeout (timers.js:214:5)
我正在尝试 运行 使用 Nightmare 的 Webpack 扩展。代码是here,但我的设置如下。
// plugin: index.js
if (process.platform === 'linux'){
xvfb.startSync()
process.env['DISPLAY'] = ':99.0'
}
var server = serve(self.outputPath)
var port = server.address().port
var outputFiles = render(port, self.routes, self.elementToWaitFor)
outputFiles.then(files => {
for (var i = 0; i < files.length; i++) {
var outputFilePath = path.join(self.outputPath, self.routes[i])
var outputFileName = path.join(outputFilePath, 'index.html')
fsPath.writeFile(outputFileName, files[i])
}
server.close(function () {
xvfb.stopSync()
done()
})
}).catch(err => {
setTimeout(function () {throw err})
server.close(function () {
xvfb.stopSync()
done()
})
})
// plugin: render.js (where `var outputFiles = render(port, self.routes, self.elementToWaitFor)` goes)
function render(port, routes, elementToWaitFor) {
var nightmare = Nightmare({
show: false,
webPreferences: {
partition: 'partition-' + Math.random()
}
})
var baseUrl = `http://localhost:${port}`
var pageContents = routes.reduce(function (accumulator, route) {
return accumulator.then(function (results) {
var url = baseUrl + route
return nightmare
.goto(url)
.wait(elementToWaitFor, 1000)
.evaluate(function () {
return document.documentElement.innerHTML
})
.then(function (content) {
results.push(content)
return results
})
.catch(err => {
setTimeout(function () {throw err})
})
})
}, Promise.resolve([]))
return pageContents.then(function (values) {
return nightmare.end().then(function () {
return values
})
}).catch(err => {
setTimeout(function () {console.log(`Error ${err}`)})
})
}
# .travis.yml (project that uses plugin)
language: node_js
node_js:
- "node"
addons:
apt:
packages:
- xvfb
- libxss1
script:
- yarn run lint
- yarn run build
// package.json
"scripts": {
"build": "DEBUG=nightmare:*,electron:* node build/build.js",
},
构建脚本 运行 是 Webpack,运行 是我的 Nightmare 脚本。 Here's a Gist with the full error log.
我已经尝试了所有可以在网上找到的解决方案,但似乎没有任何效果。
我尝试过的一些事情(我记得:
Nightmare({show: false})
Nightmare({webPreferences: {partition: 'partition-' + Math.random()}
- 为
.wait()
添加超时
- 根据不同的在线帖子建议添加更多
apt
包 - 一大堆其他的,应该写下来。
任何帮助将不胜感激,如果我遗漏了什么,请告诉我!
这似乎已通过将 sudo: required
添加到我的 .travis.yml
来解决。