getsentry / sentry-react-native

Official Sentry SDK for React Native
https://sentry.io
MIT License
1.57k stars 332 forks source link

[Sentry] Failed to read default Babel transformer path: Error: ENOENT: no such file or directory #4121

Open feidaZhang opened 1 day ago

feidaZhang commented 1 day ago

OS:

Platform:

SDK:

SDK version: 5.30.0

react-native version: 0.72.12

Are you using Expo?


I have the following issue:

After integrating withSentryConfig in the metro.config.js, annotateReactComponents is true, we found that when building iOS application through Xcode in debug mode, the .sentry/. defaultBabelTransformerPath file was first created and then deleted before the build was completed. However, when loading the JS Bundle, sentry tried to read the file again and threw an error.

Actual result:

Image

Expected result:

no error

feidaZhang commented 1 day ago

if i comment this line. There is no error but the file can not be deleted automatically.

function withSentryBabelTransformer(config) {
    const defaultBabelTransformerPath = config.transformer && config.transformer.babelTransformerPath;
    utils_1.logger.debug('Default Babel transformer path from `config.transformer`:', defaultBabelTransformerPath);
    if (!defaultBabelTransformerPath) {
        // This has to be console.warn because the options is enabled but won't be used
        // eslint-disable-next-line no-console
        console.warn('`transformer.babelTransformerPath` is undefined.');
        // eslint-disable-next-line no-console
        console.warn('Sentry Babel transformer cannot be used. Not adding it...');
        return config;
    }
    if (defaultBabelTransformerPath) {
        (0, sentryBabelTransformerUtils_1.saveDefaultBabelTransformerPath)(defaultBabelTransformerPath);
        process.on('exit', () => {
             // comment this line
            // (0, sentryBabelTransformerUtils_1.cleanDefaultBabelTransformerPath)();
        });
    }
    return Object.assign(Object.assign({}, config), { transformer: Object.assign(Object.assign({}, config.transformer), { babelTransformerPath: require.resolve('./sentryBabelTransformer') }) });
}
feidaZhang commented 1 day ago

It's my device info. Model Name: MacBook Pro Model Identifier: MacBookPro17,1 Model Number: Z11C000BPCH/A Chip: Apple M1

kahest commented 7 hours ago

Thanks @feidaZhang for the report, we'll investigate this and follow up here