Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: safeguard against undefined entry #14068

Merged
merged 3 commits into from
Aug 27, 2021
Merged

fix: safeguard against undefined entry #14068

merged 3 commits into from
Aug 27, 2021

Conversation

rigor789
Copy link
Contributor

The fix for #14028 added in #14030 does not catch cases where entry may be undefined.

Starting with 5.51.0 we're seeing errors like this one (even with 5.51.1):

/test/node_modules/webpack/lib/FileSystemInfo.js:817
if (entry.resolved !== undefined) return entry.resolved;
^

TypeError: Cannot read property 'resolved' of undefined
at getResolvedTimestamp (/test/node_modules/webpack/lib/FileSystemInfo.js:817:12)
at /test/node_modules/webpack/lib/FileSystemInfo.js:1167:21
at /test/node_modules/webpack/lib/util/AsyncQueue.js:352:5
at Hook.eval [as callAsync] (eval at create (/test/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), :4:1)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/test/node_modules/webpack/node_modules/tapable/lib/Hook.js:18:14)
at AsyncQueue._handleResult (/test/node_modules/webpack/lib/util/AsyncQueue.js:322:21)
at /test/node_modules/webpack/lib/util/AsyncQueue.js:305:11
at /test/node_modules/webpack/lib/FileSystemInfo.js:3098:21
at /test/node_modules/webpack/lib/FileSystemInfo.js:3010:22
at /test/node_modules/neo-async/async.js:2830:7
at done (/test/node_modules/neo-async/async.js:2925:13)
at /test/node_modules/webpack/lib/FileSystemInfo.js:2994:23
at Array. (/test/node_modules/webpack/lib/util/fs.js:311:21)
at runCallbacks (/test/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:27:15)
at /test/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:200:4
at callback (/test/node_modules/graceful-fs/polyfills.js:299:20)

What kind of change does this PR introduce?

bugfix

Did you add tests for your changes?

N/A

Does this PR introduce a breaking change?

No

What needs to be documented once your changes are merged?

N/A

@webpack-bot
Copy link
Contributor

For maintainers only:

  • This needs to be documented (issue in webpack/webpack.js.org will be filed when merged)
  • This needs to be backported to webpack 4 (issue will be created when merged)

@alexander-akait
Copy link
Member

Please add tests

@alexander-akait
Copy link
Member

alexander-akait commented Aug 25, 2021

We should found a place/situation where we return undefined to avoid monkey patching without tests

@rigor789
Copy link
Contributor Author

I'm sorry, but not familiar with how exactly this is used, or when this case is called to add a test or figure out why/when it may end up being undefined. Perhaps @sokra would know best, since he added the getResolvedTimestamp and getResolvedHash functions.

Willing to help, just not sure how.

@alexander-akait
Copy link
Member

@rigor789 Can you show arguments here

const resolved = getResolvedTimestamp(entry);

@alexander-akait
Copy link
Member

For this.contextTimestampQueue.add(path, (err, entry) => {

@rigor789
Copy link
Contributor Author

Ok that does give a clue what's going on. There's an err and entry is undefined.

We are using a virtual entry file, ie. it doesn't exist on the filesystem using https://github.com/sysgears/webpack-virtual-modules.

Screenshot 2021-08-25 at 10 19 33 PM

@alexander-akait
Copy link
Member

To be honestly webpack never supports Webpack Virtual Modules, it is always have problems...

@alexander-akait
Copy link
Member

Cache will be broken too

@sokra
Copy link
Member

sokra commented Aug 26, 2021

entry should never be undefined. Here err is not handled correctly, which is causing this problem.

@webpack-bot
Copy link
Contributor

Thank you for your pull request! The most important CI builds succeeded, we’ll review the pull request soon.

@sokra sokra merged commit ebb7f61 into webpack:main Aug 27, 2021
@rigor789 rigor789 deleted the patch-2 branch August 27, 2021 18:30
@Akryum
Copy link
Contributor

Akryum commented Sep 2, 2021

Hi, thanks for the fix! Do you have an estimate for a release?

@alexander-akait
Copy link
Member

Near future, we need fix one critical bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants