gpt4 book ai didi

webpack - Nightmare 在特拉维斯坠毁: `nightmare:log crashed [{},false]`

转载 作者:行者123 更新时间:2023-12-03 13:24:09 27 4
gpt4 key购买 nike

我很难过要在Travis CI上运行它。它会间歇性地工作,但 Nightmare 通常会因以下错误而失败:

  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,该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中,似乎可以解决此问题。

    关于webpack - Nightmare 在特拉维斯坠毁: `nightmare:log crashed [{},false]` ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43624960/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com