40thieves/webpack-sentry-plugin

Error when deleteFiles is called

aroc opened this issue · 7 comments

aroc commented

I'm encountering the following error from inside this plugin when I run my webpack build:

[ERR_INVALID_ARG_TYPE]: The "path" argument must be one of type string, Buffer, or URL. Received type undefined
    at Object.unlinkSync (fs.js:949:3)
    at /root/project/js/webapp/node_modules/webpack-sentry-plugin/dist/index.js:261:22

Node version: 10.15.1
Webpack Version: 4.28.3
babel-core version: 7.0.0
webpack-Sentry-plugin version: 1.16.0
OS: MacOS 10.14.3

My config:

plugins : [
        ...configuration.plugins, 
        new SentryPlugin({
            organization       : 'my_org_name',
            project            : 'my_project_name',
            apiKey             : SENTRY_RELEASE_API_KEY,
            deleteAfterCompile : true,
            filenameTransform  : (filename) => {
                return `~/static/dist/${filename}`;
            },
            release : (hash) => {
                return hash; // webpack build hash
            },
            suppressConflictError : true,
        }),
    ],

Any thoughts on what could be happening here?

Same on windows server 2012R2, but this doesn't occur on win 10.
The workaround is to set deleteAfterCompile false and then delete the source-map files manually. But I have no idea how this's happening...

Hmm. The error means that when webpack-sentry-plugin tries to delete your sourcemaps, it finds that the sourcemap file on your filesystem does not exist/has already been deleted. I would not be surprised in @codingbeans' case if there was a weird Windows filesystem behaviour causing this, I've only used this option on a linux server.

I am curious if this is related to #78. @aroc do you still have this problem with version 2.0.1?

#78 (comment)

version 2.0.1 also have same question.

11bit commented

Looks like if there is an error somewhere else before the sentry-webpack-plugin then existsAt will be undefiend which leads to exception that also hides a real reason behind the error.
What do you think about adding a check before trying to delete a file?

if (filePath) fs.unlinkSync(filePath)

Yeah I would be happy to merge a PR that adds a sanity check like that. I think it would also make sense to add a warning if the file does not exist (since in theory this should never happen unless there was a different error in the build)

I am closing this issue since #85 added a sanity check that in theory should prevent this. Feel free to follow up if you still experience a problem.