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(server): error on unknown filetypes #3601

Closed
wants to merge 1 commit into from

Conversation

johnjbarton
Copy link
Contributor

BREAKING CHANGE:
Previously file types that were not given in the config and could not be
determined from the file extension were treated as .js. That can lead
to loading extra or incorrect files.
Now we emit an ERROR and skip any files that cannot be classified.

BREAKING CHANGE:
  Previously file types that were not given in the config and could not be
  determined from the file extension were treated as .js.  That can lead
  to loading extra or incorrect files.
  Now we emit an ERROR and skip any files that cannot be classified.
@AppVeyorBot
Copy link

Build karma 2816 completed (commit 0868013829 by @johnjbarton)

@karmarunnerbot
Copy link
Member

Build karma 419 completed (commit 0868013829 by @johnjbarton)

@karmarunnerbot
Copy link
Member

Build karma 418 completed (commit 0868013829 by @johnjbarton)

@devoto13
Copy link
Collaborator

I don't think this is a good change.

It results in worse developer experience. Compare "My tests crashed. I check Karma logs and understand why. I see message explaining that my files have incorrect type." before vs. "My tests silently passed, but some of them were not run and I didn't noticed as I never checked Karma logs." with this change. So when users upgrade to Karma 6, some tests may stop running, but it is hard to notice (in particular in CI environment, where it will be just a line in logs, not a failed test run). And for other part of users tests will start crashing because of missing files for no good reason creating annoyance.

If we want to make something in this area it should probably happen up the stack (during config validation or when we create File objects) and be first rolled out as a warning mentioning that this warning will become a hard error in the next major release (so people have time to adapt) and then in the next major release actually throw a hard error, which will prevent Karma from running.

@johnjbarton
Copy link
Contributor Author

Ah, so your theory is that some of the incorrect file types are actually things needed for tests to pass?
I think they are eg .wav files.

@johnjbarton
Copy link
Contributor Author

How will a warning in the config file differ from the warning now? Yes, it is better to validate in the config file analysis phase, but will users pay any more attention?

Seems like the other option is to fail these cases outright: you have to pass correct file name or correct file types. Is there a use case for the current silently-treat-as-js ?

@devoto13
Copy link
Collaborator

devoto13 commented Dec 23, 2020

Ah, so your theory is that some of the incorrect file types are actually things needed for tests to pass?
I think they are eg .wav files.

Yeah, exactly! I would expect some people to just ignore the warning right now as it's just a warning and rely on the fallback to JS. I can think of case like myfile.cjs, myfile.mjs or some extension-less URL where fallback works fine.

How will a warning in the config file differ from the warning now? Yes, it is better to validate in the config file analysis phase, but will users pay any more attention?

Seems like the other option is to fail these cases outright: you have to pass correct file name or correct file types.

I agree that this feature will also catch valid errors as you say (e.g. .wav, .jpg, etc) and it is useful to notify user about such cases. But I think that we should be loud about such cases and fail (not just print into logs). So, yeah, I'm for failing outright with the transition period to not affect existing users relying on the fallback.

Is there a use case for the current silently-treat-as-js ?

See above for .cjs, .mjs, extension-less URLs (for example https://unpkg.com/jquery will redirect to the JS file, but it does not have .js in the URL). IMO it is reasonable to ask users to specify type explicitly for them. Just need to communicate it clearly.

@johnjbarton johnjbarton closed this Mar 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants