parcel-plugin-sw-precache
parcel-plugin-sw-precache copied to clipboard
UnhandledPromiseRejectionWarning: Error: The bundler properties/sub-properties (mainBundle / entryAsset) seems to be not present
My Code working fine before, after added this plugin in parcel bundler giving this error
√ Built in 29.18s.
(node:2992) UnhandledPromiseRejectionWarning: Error: The bundler properties/sub-properties (mainBundle / entryAsset) seems to be not present
at Bundler.<anonymous> (D:\rpkct\rpk\PWA\submission2\project\node_modules\parcel-plugin-sw-precache\index.js:36:13)
at Bundler.emit (events.js:310:20)
at Bundler.bundle (D:\rpkct\rpk\PWA\submission2\project\node_modules\parcel-bundler\src\Bundler.js:340:12)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:2992) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:2992) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I think this error come from unhandled promise rejection, but i have been added .catch in my code. here data-source.js
const BASE_URL = "https://api.football-data.org";
class DataSource {
static getStanding(type) {
return fetch(BASE_URL + "/v2/competitions/2001/standings?standingType=" + type, {
method: "GET",
headers: {
"X-Auth-Token": "xxxxxx"
}
})
.then(response => response.json())
.then(responseJson => {
if (responseJson.standings) {
return Promise.resolve(responseJson.standings);
} else {
return Promise.reject("standing" + type + "is empty");
}
})
.catch(error => {
alert(error);
})
}
}
export default DataSource;
which parcel version are you using?
you occurs this error because the plugin is not able to get the package.json
file in ur project
so how to handle this ?
So which version you are on? Could you show me a minimal repo to reproduce it?
this is the version of my parcel. and i'm using latest parcel-plugin-sw-precache
Same - I installed it on this repo: https://github.com/remy/zx-tools/ - then ran npm run build
(and running the same version of parcel as @AnandaDwiprayoga).
@remy i get the cause of this. it happens when you try to build multiple entries at the same time.
in this case parcel triggers the plugin with bundler.mainBundle.entryAsset
is null
which i didn't consider it to be before.