Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Webpack 梦魇撞击特拉维斯:`梦魇:日志撞击[{},错]`_Webpack_Travis Ci_Headless_Nightmare - Fatal编程技术网

Webpack 梦魇撞击特拉维斯:`梦魇:日志撞击[{},错]`

Webpack 梦魇撞击特拉维斯:`梦魇:日志撞击[{},错]`,webpack,travis-ci,headless,nightmare,Webpack,Travis Ci,Headless,Nightmare,我在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-tfSpn0qi1SFdUf

我在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)
我正在尝试运行一个使用噩梦的网页扩展。代码是,但是我的设置如下

// 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()
        })
    })


构建脚本运行Webpack,它运行我的噩梦脚本

我已经尝试了在网上找到的每一个解决方案,但似乎没有任何效果

我尝试过的一些事情(我记得:

  • 噩梦({show:false})
  • 噩梦({webPreferences:{partition:'partition-'+Math.random()}
  • 将超时添加到
    .wait()
  • 添加更多的
    apt
    软件包作为不同的在线帖子
  • 还有一大堆人,应该写下来

任何帮助都将不胜感激,如果我遗漏了什么,请告诉我!

这似乎已经通过在我的
.travis.yml
中添加
sudo:required
解决了

// 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",
  },