The function signature of detectType says that it always returns a string, however this is not true, in certain cases it returns void and logs a message.
mw.log( 'Error: could not detect type of media src: ' + uri );
It would be better to either:
- return an empty string
- throw an exception in this case so that a stake trace is visible in Logstash and actionable. Given there is no exception, the error is currently materializing further down the stack as TypeError: undefined is not an object (evaluating 'this.getMIMEType')
2 should only occur if there is an intention to fix the underlying error.