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

Reject payloads before they are sent to APNs if they're too large #31

Open
TysonAndre opened this issue Oct 13, 2020 · 1 comment
Open

Comments

@TysonAndre
Copy link

TysonAndre commented Oct 13, 2020

Request ended with status 413 and responseData: {"reason":"PayloadTooLarge "}

https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CreatingtheNotificationPayload.html#//apple_ref/doc/uid/TP40008194-CH10-SW1 indicates that

  • For regular remote notifications, the maximum size is 4KB (4096 bytes)
  • For Voice over Internet Protocol (VoIP) notifications, the maximum size is 5KB (5120 bytes)

For example, add a default of 4096 bytes, and allow it to be overridden to a larger positive integer for VoIP or to account for future changes to APNs limits

  • Buffer.from(string) can be used to convert the raw payload to the bytes to send, and buffer.length gets the length in bytes (instead of codepoints)

If, for example, a client were to attempt to send a JSON payload that was 1 megabyte in size due to failing to truncate part of the input, it would be useful to prevent something that would definitely fail from being sent to APNs, especially if it blocked other requests to APNs or APNs server closes the connection (haven't checked if they currently do that).

(lib/provider.js is what does the final JSON.stringify)

@mtrezza mtrezza changed the title Idea: Reject payloads before they are sent to APNs if they're too large? Reject payloads before they are sent to APNs if they're too large? Mar 27, 2022
@parse-github-assistant
Copy link

parse-github-assistant bot commented Mar 27, 2022

Thanks for opening this issue!

  • ❌ Please edit your post and use the provided template when creating a new issue. This helps everyone to understand your post better and asks for essential information to quicker review the issue.

@mtrezza mtrezza changed the title Reject payloads before they are sent to APNs if they're too large? Reject payloads before they are sent to APNs if they're too larg Mar 27, 2022
@mtrezza mtrezza changed the title Reject payloads before they are sent to APNs if they're too larg Reject payloads before they are sent to APNs if they're too large Mar 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants