Skip to content

isBinaryFile considers certain protobuf binary files as text #3405

Closed
@darrnshn

Description

@darrnshn

Expected behaviour

Protobuf binary files considered binary.

Actual behaviour

Protobuf binary files not considered binary.

Environment Details

  • Karma version: v4.4.1
  • Karma config:
module.exports = function(config) {
  config.files.push({
    pattern: 'test/**',
    watched: false,
    served: true,
    nocache: false,
    included: false,
  });
};

Steps to reproduce the behaviour

I don't have a small repro unfortunately, but the root cause is simple. isBinaryFile uses heuristics for detecting binary files. In our case, some of our protobuf files happened to be classified as text even though they are binary, so Karma calls buffer.toString(), which creates a bunch of unicode replacement characters that the protobuf parser can't interpret.

Could we add a way to override the result of isBinaryFile via karma files config? maybe something like:

module.exports = function(config) {
  config.files.push({
    pattern: 'test/**',
    watched: false,
    served: true,
    nocache: false,
    included: false,
    isBinary: true,
  });
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions