
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
A better way to handle errors
Unlike with try...catch or promises:
$ npm install betterr
import { betterr } from 'betterr'; // const { betterr } = require('betterr');
const [user, err] = await betterr(() => getUserWithId(1));
// user: User | null, err: Error | null
Avoid handling the error, and use optional chaining
const maybeName = user?.name; // maybeName: string | undefined
Handle the error (interrupting the control flow), after which optional chaining is not needed
if (err) return; // user: User (after error handled)
const name = user.name; // name: string
betterr
/ betterSync
execute a callback and return a tuple with data
(callback return value) and err
(error during execution), one of which will be null depending on the success of the callback.
betterr
can be used with both asynchronous and synchronous callbacks.
betterrSync
can only be used with synchronous callbacks, but avoids wrapping the data in a promise so that await
is not necessary.
Both betterr
and betterrSync
are generic.
data
). It defaults to the callback return type.err
) must extend the Error
object. It defaults to Error
./**
* const betterrSync: <TData, TError extends Error = Error>
* (callback: () => TData) => [TData, null] | [null, TError]
*/
const [user, err] = betterrSync<User, RangeError>(() => ({ id: 1 }));
// data: User | null, err: RangeError | null
6.0.0
FAQs
A better way to handle errors
The npm package betterr receives a total of 5 weekly downloads. As such, betterr popularity was classified as not popular.
We found that betterr 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.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.