Prompt
How do I debug web push notifications that never arrive?
Latest observation
Here’s a practical checklist for debugging web push notifications that “send” but never arrive.
1) Verify the full delivery path
Web push has several hops:
- Your app creates a subscription
- Browser gives you an endpoint + keys
- Your server sends a push request to the push service
- Push service delivers to the browser
- Service worker receives the push and shows a notification
A failure can happen at any step, so debug each one separately.
2) Confirm the subscription is valid
On the client, log the subscription object:
const sub = await registration.pushManager.getSubscription();
console.log(sub && sub.toJSON());
Check:
endpointis presentkeys.p256dhandkeys.authexist- You’re using the current subscription, not a stale one
- The user has not unsubscribed or cleared site data
If you don’t have a subscription, the browser can’t receive anything.
3) Ensure the site has permission
Check notification permission:
console.log(Notification.permission); // "granted", "denied", or "default"
Things to verify:
- Permission is granted
- You requested permission from a user gesture
- The origin is secure: HTTPS (except
localhost)
If permission is denied, push may still arrive at the service worker, but notifications won’t display.
4) Check your service worker
Make sure the service worker is registered and active:
navigator.serviceWorker.ready.then(reg => console.log(reg.active));
In the service worker, verify you have a push event handler:
self.addEventListener("push", event => {
console.log("push received", event);
});
And that you actually show a notification:
self.addEventListener("push", event => {
const data = event.data ? event.data.json() : {};
event.waitUntil(
self.registration.showNotification(data.title || "Test", {
body: data.body || "No body",
})
);
});
Common mistake: receiving the push but never calling showNotification().
5) Check browser console and service worker logs
Service worker logs are easy to miss.
In Chrome/Edge:
- Open DevTools
- Go to Application → Service Workers
- Click Inspect on the service worker
Then watch the service worker console for errors such as:
- malformed payload
- JSON parsing errors
- missing
event.waitUntil() - exceptions before
showNotification()
6) Inspect server response from the push provider
If you send push via Web Push protocol, your server should log the response from the push service.
Typical issues:
401 Unauthorized/403 Forbidden- bad VAPID keys or JWT
- wrong audience/origin
404 Not Found/410 Gone- subscription expired or invalid
- need to remove the subscription and re-subscribe
413 Payload Too Large- payload too big
400 Bad Request- invalid payload encoding or headers
If your push library returns a response object, log it.
Example (Node + web-push):
try {
const result = await webpush.sendNotification(subscription, payload);
console.log("sent", result);
} catch (err) {
console.error("push failed", err.statusCode, err.body || err);
}
7) Validate VAPID configuration
If you use VAPID, confirm:
- Public/private keys match
- The same public key was used to subscribe the user
- Your JWT audience matches the push service endpoint
- Your
subjectis valid, likemailto:admin@example.com
A mismatch here often produces 401/403 errors.
8) Check payload format
If the push arrives but your handler crashes, the notification may never appear.
Example correct parsing:
self.addEventListener("push", event => {
let data = {};
if (event.data) {
try {
data = event.data.json();
} catch {
data = { body: event.data.text() };
}
}
event.waitUntil(
self.registration.showNotification(data.title || "Hello", {
body: data.body || "New message",
})
);
});
If you send plain text but call event.data.json(), that throws.
9) Test with a minimal push payload
Reduce complexity:
- send a tiny test payload
- hardcode a simple notification
- avoid app logic, DB reads, and complex parsing
Example minimal service worker:
self.addEventListener("push", event => {
event.waitUntil(
self.registration.showNotification("Test push", {
body: "If you see this, push works",
})
);
});
If this works, the problem is in your app logic, not push delivery.
10) Check browser and OS behavior
Push notifications can be blocked by:
- OS-level notification settings
- Browser quiet notification UI / notification suppression
- Battery saver / focus assist / do not disturb
- Background restrictions on mobile
- Browser not installed/unsupported in some environments
Also note:
- Some browsers behave differently on Android vs desktop
- iOS web push has special requirements and limitations
11) Make sure your push event isn’t being dropped
If the service worker script errors out during install/update, push handling may not work as expected.
Check:
- The service worker file is accessible
- It’s not returning a 404
- It has no syntax errors
- It’s controlling the page you’re testing
In the console:
navigator.serviceWorker.controller
If null, you may be testing with a page not controlled by the active worker.
12) Confirm the subscription endpoint hasn’t changed
Subscriptions can expire or be replaced. Re-subscribe when:
- user clears site data
- permission changes
- browser updates
- push service returns
410 Gone
Store subscriptions carefully and handle refresh/re-subscribe flows.
13) Try a known-good push test tool
Use browser devtools or a push test utility:
- Chrome DevTools service worker push simulation
- Firebase Cloud Messaging debug tools if using FCM
web-pushCLI/library for raw Web Push testing
This helps determine whether:
- the service worker is fine
- the server send is fine
- the issue is in the client app logic
14) Add logging at each layer
Add logs for:
- subscription creation
- server send attempt
- server response
- service worker push event
- notification display
- notification click
For example:
self.addEventListener("push", event => {
console.log("push event", event);
event.waitUntil(
self.registration.showNotification("Debug", { body: "Push received" })
.then(() => console.log("notification shown"))
.catch(err => console.error("showNotification failed", err))
);
});
15) Common root causes
Most “never arrives” problems are usually one of these:
- stale/invalid subscription
- permission not granted
- service worker not registered/active
- payload parsing error
- server auth/VAPID issue
- push service returned 410/401/403
- notification blocked by OS/browser settings
- forgetting to call
showNotification()
If you want, I can give you:
- a step-by-step debugging flowchart, or
- a minimal working web push example for client + service worker + server.