vitedge: error on deloy

When I am running yarn deploy after yarn build, it yields error.

Built successfully, built project size is 757 KiB.
πŸŒ€  Using namespace for Workers Site "__cool-workers_sites_assets"
✨  Success
πŸŒ€  Uploading site files
Error: Something went wrong! Status: 400 Bad Request, Details {
  "result": null,
  "success": false,
  "errors": [
    {
      "code": 10021,
      "message": "Script startup timed out.\n"
    }
  ],
  "messages": []
}

error Command failed with exit code 1

Have you see this issue? I was talking to Greg about this, he says it is an issue when too many things being initialized as globals

addEventListener('fetch', event => {
  event.respondWith(handleRequest(event.request)
})

const doWork = async () => { /* ... */ }

const handleRequest = async request => {
  const results = await doWork()
  return new Response(JSON.stringify(results))
}

vs.

addEventListener('fetch', event => {
  event.respondWith(handleRequest(event.request)
})

const results = /* ... */

const handleRequest = async request => {
  return new Response(JSON.stringify(results))
}

The first example (good) does the work in the request/response phase, with just the function declaration in the global state.

The second example (bad) does the work in the global state.

Do you know how to fix this?

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 16 (6 by maintainers)

Most upvoted comments

@subhendukundu I’ve checked this for a shameful amount of hours and finally found something in the Webpack configuration that affects it. I don’t think the error is completely gone because it depends on the app dependencies, but it must be reduced now (I could deploy https://analytics-test.zable.workers.dev/).

Update to Vitedge 0.10.5 and add the following to your Webpack config:

const vitedgeWebpack = require("../node_modules/vitedge/webpack.cjs");

const config = vitedgeWebpack();
config.resolve.mainFields = ["browser", "module", "main"];

module.exports = {
  ...config,
};

For the record, I tried removing all the internal code that Vitedge adds and it was still failing before changing webpack, so I don’t think it is related to Vitedge itself. In fact, I removed all your app code except dependencies (d3, nhost, etc) and still failed randomly.