You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a script throws an error, the cause of the error should be printed out to console or simply provided as part of an error.
Actual Behavior
When a script throws an error, the renderStepsErrors tries to read the file of the migration script based on the stack using callsites. Unfortunately, when the types is set to module, the filename produced is a file://string. So when it is passed into fs.readFileSync, node throws an ENOENT error, as fs can't handle file:// string values.
Possible Solution
Try to replace file:// from the filename returned by callsites before passing it to fs.readFileSync.
Steps to Reproduce
Create a project with "type": "module" in the package.json
Create a migration script that will fail (e.g. try to create a content type that already exists)
Run the migration script
Context
We have a TypeScript project where some important libraries are ESM only, so we're migrating all of our code to produce ESM JavaScript. Our migration scripts are working perfectly fine and we can run them against Contentful, but when an error occurs (e.g. a script has run twice), we don't get a useful error message, just a stacktrace stating that one of the migration files can't be found, even though it exists. This means that we can't see what is the actual issue causing the script to fail.
Environment
Node Version: v18.16.1
Package Manager Version: yarn 3.6.0
Operating System: Darwin BMI05110.local 22.6.0 Darwin Kernel Version 22.6.0: Wed Jul 5 22:22:05 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T6000 arm64
Package Version: v10.39.2
The text was updated successfully, but these errors were encountered:
Expected Behavior
When a script throws an error, the cause of the error should be printed out to console or simply provided as part of an error.
Actual Behavior
When a script throws an error, the
renderStepsErrors
tries to read the file of the migration script based on the stack using callsites. Unfortunately, when thetypes
is set tomodule
, the filename produced is afile://
string. So when it is passed intofs.readFileSync
, node throws an ENOENT error, asfs
can't handlefile://
string values.Possible Solution
Try to replace
file://
from the filename returned by callsites before passing it tofs.readFileSync
.Steps to Reproduce
"type": "module"
in thepackage.json
Context
We have a TypeScript project where some important libraries are ESM only, so we're migrating all of our code to produce ESM JavaScript. Our migration scripts are working perfectly fine and we can run them against Contentful, but when an error occurs (e.g. a script has run twice), we don't get a useful error message, just a stacktrace stating that one of the migration files can't be found, even though it exists. This means that we can't see what is the actual issue causing the script to fail.
Environment
The text was updated successfully, but these errors were encountered: