GitShow/sindresorhus/p-state
sindresorhus

p-state

Inspect the state of a promise

by sindresorhus
inspectintrospectionnpm-packagepromise
Star on GitHubForknpm

JavaScript

134 stars7 forks2 contributorsQuiet · 9mo agoSince 2020MIT

Meet the team

See all 2 on GitHub →
sindresorhus
sindresorhus21 contributions
Richienb
Richienb4 contributions

Recent fixes

View closed PRs →
CloudNStoyan
`promiseStateAsync` swallows unhandled rejections if they are rejected after being observed by the `Promise.race`ClosedIssue

Using the following snippet, will swallow unhandled rejections if the promise is rejected after being inspected by Note: in the browser I used the following events to check if the unhandled rejection event is raised, which it wasn't: This behavior is seen in both Node and browsers I have tested it on the following platforms: Win11 Chrome Version 122.0.6261.129 Win11 Firefox Version 123.0.1 macOS Sonoma 14.4 Chrome Version 122.0.6261.129 macOS Sonoma 14.4 Firefox Version 123.0.1 macOS Sonoma 14.4 Safari Version 17.4 (19618.1.15.11.12) Node versions v18.16.1 and v20.11.0 on both Win11 and macOS Sonoma 14.4

CloudNStoyan · 9mo ago
CloudNStoyan
`promiseStateAsync` still swallows unhandled rejections when used in the browser because of `setTimeout`ClosedIssue

Using the function in a browser will not trigger the event. This seems to happen because of the , by default when the arg is omitted its set to , and with this configuration the unhandled rejection is still swallowed by . Changing the delay to instead of fixed it for me. The fix: Note: on Firefox you get a in the Dev Tools but it doesn't trigger the event. !image I have tested this behavior on these platforms: Win11 Chrome Version 122.0.6261.129 Win11 Firefox Version 123.0.1 macOS Sonoma 14.4 Chrome Version 122.0.6261.129 macOS Sonoma 14.4 Firefox Version 123.0.1 macOS Sonoma 14.4 Safari Version 17.4 (19618.1.15.11.12)

CloudNStoyan · 2y ago
fregante
`promiseStateAsync` handles errors (observer effect)ClosedIssue

Rejected promises show up as uncaught errors in the console and cause Node 15 to exit with 1. however handles these errors and they're no longer reported by either platform. Example: Chrome:

fregante · 2y ago
Structured data for AI agents

Repository: sindresorhus/p-state. Description: Inspect the state of a promise Stars: 134, Forks: 7. Primary language: JavaScript. License: MIT. Topics: inspect, introspection, npm-package, promise. Open PRs: 0, open issues: 0. Last activity: 9mo ago. Top contributors: sindresorhus, Richienb.

·@ofershap

Replace github.com with gitshow.dev