Common issues
Response is returned instead of AsyncGenerator
Symptom
When you callmeros(response), you get back the original response object instead of an async generator.
Cause
Meros only processes responses with amultipart/ content type. If the response is not multipart, Meros returns the original response object unchanged.
Solution
Check if the response is actually multipart before iterating:This behavior is intentional and allows Meros to work as middleware that gracefully handles both multipart and non-multipart responses.
Boundary not detected
Symptom
The async generator doesn’t yield any parts, or yields incomplete data.Cause
The boundary parameter may be missing or incorrect in theContent-Type header.
Solution
Ensure your server sends a properContent-Type header:
JSON parsing fails silently
Symptom
Parts that should contain JSON havejson: false and body is a string/Buffer.
Cause
The part doesn’t have aContent-Type: application/json header, or the JSON is malformed.
Solution
Ensure each multipart part includes the correct content type header:- The part has a
Content-Typeheader - The content type includes
application/json - The JSON is valid
Body is already consumed
Symptom (Browser only)
Error: “body stream already read” or Meros returns the response unchanged.Cause
The response body can only be read once. If you’ve already called.json(), .text(), or iterated over the body, it cannot be read again.
Solution
Pass the response directly to Meros without reading it first:Meros checks
response.bodyUsed in the browser and will return the response unchanged if the body has already been consumed.UTF-8 characters are corrupted
Symptom
Emoji or special characters appear as � or corrupted text.Cause
Multibyte UTF-8 characters may be split across chunk boundaries during streaming.Solution
Meros handles this automatically! The browser implementation usesTextDecoder with { stream: true }, which properly handles UTF-8 characters split across chunks.
If you’re seeing corruption, verify:
- Your server is sending UTF-8 encoded data
- Your server includes proper charset in Content-Type:
Content-Type: application/json; charset=utf-8
Preamble or epilogue appears in parts
Symptom
Text before the first boundary or after the final boundary appears as a part.Solution
This should not happen - Meros is designed to ignore preamble (content before first boundary) and epilogue (content after final boundary). The final boundary must end with--:
Browser-specific issues
Module not found: ‘meros’
Solution
Use the environment-specific import:ReadableStream is not defined
Cause
Your environment doesn’t support ReadableStream (very old browsers).Solution
Meros requires modern browser APIs. Ensure your target browsers support:ReadableStreamTextDecoder- Async iterators
Node-specific issues
IncomingMessage is not supported
Cause
You’re using the browser version of Meros in Node.js.Solution
Use the Node-specific import:Buffer vs string confusion
Issue
In Node.js, non-JSON bodies areBuffer objects, not strings.
Solution
Convert to string explicitly:Getting help
If you encounter an issue not covered here:- Check the API Reference for correct usage
- Review the examples in the GitHub repository
- Search existing issues on GitHub
- Open a new issue with a minimal reproduction
When reporting issues, include:
- Your environment (browser/Node version)
- The Content-Type header from your response
- A minimal code example that reproduces the issue