Emit file metadata with data and error events
Guard against multiple loads overwriting the monkey-patched function