
Security News
GitHub Actions Adds cache-mode to Limit Cache Poisoning Risk
GitHub Actions now supports cache-mode, a least-privilege control on the Actions cache aimed at the cache poisoning technique behind recent compromises.
ts-try-async
Advanced tools
TypeScript-first async error handling utility with typed Result pattern.
Convert thrown exceptions into typed, predictable result objects — no more try/catch blocks scattered everywhere.
npm install ts-try-async
import { tryAsync } from 'ts-try-async'
const result = await tryAsync(() => fetchUser(id))
if (result.success) {
console.log(result.result) // User object, fully typed
} else {
console.log(result.message) // Error message string
console.log(result.cause) // Original error for debugging
}
TypeScript automatically narrows the type — result.result only exists when success === true.
const result = await tryAsync(
() => fetchUser(id),
{
onError: (error, message) => {
// error: full Error object with stack trace
// message: normalized string
Sentry.captureException(error)
logger.error(message)
}
}
)
Wrap a function once, reuse everywhere:
import { withTryAsync } from 'ts-try-async'
const safeFetchUser = withTryAsync(fetchUser)
const result = await safeFetchUser(id) // Returns AsyncResult<User>
With options:
const safeFetchUser = withTryAsync(fetchUser, {
onError: (error) => Sentry.captureException(error)
})
tryAsync<T>(fn, options?): Promise<AsyncResult<T>>Executes an async function and returns a result object.
| Parameter | Type | Description |
|---|---|---|
fn | () => Promise<T> | Async function to execute |
options.onError | (error: unknown, message: string) => void | Optional error callback |
withTryAsync<TArgs, TReturn>(fn, options?)Wraps an async function to return AsyncResult instead of throwing.
| Parameter | Type | Description |
|---|---|---|
fn | (...args: TArgs) => Promise<TReturn> | Async function to wrap |
options.onError | (error: unknown, message: string) => void | Optional error callback |
type AsyncResult<T> = AsyncSuccess<T> | AsyncError
interface AsyncSuccess<T> {
success: true
result: T
}
interface AsyncError {
success: false
message: string
cause: unknown
}
interface TryAsyncOptions {
onError?: (error: unknown, message: string) => void
}
cause or onError callbackMIT
FAQs
TypeScript-first async error handling utility with typed Result pattern
We found that ts-try-async demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.

Security News
GitHub Actions now supports cache-mode, a least-privilege control on the Actions cache aimed at the cache poisoning technique behind recent compromises.

Company News
Allow myself to introduce... myself.

Research
/Security News
A Twitch browser extension on Chrome and Firefox forwards users’ live OAuth session tokens through proxies controlled by a Russian bot service.