
Security Fundamentals
Turtles, Clams, and Cyber Threat Actors: Shell Usage
The Socket Threat Research Team uncovers how threat actors weaponize shell techniques across npm, PyPI, and Go ecosystems to maintain persistence and exfiltrate data.
`Promise#finally()` ponyfill - Invoked when the promise is settled regardless of outcome
The p-finally npm package is designed to allow you to attach a handler that will be called when a promise is settled (either fulfilled or rejected). This is useful for running cleanup code or finalizing operations, regardless of the promise's outcome.
Attaching a finally handler to a promise
This feature allows you to execute code after a promise has been settled, regardless of whether it was fulfilled or rejected. It's particularly useful for cleanup operations.
const pFinally = require('p-finally');
const promise = new Promise((resolve, reject) => {
// Some asynchronous operation
});
pFinally(promise, () => {
// Code to run on promise settlement
});
Bluebird is a comprehensive promise library that includes a .finally() method among its wide array of features. Compared to p-finally, Bluebird offers a much broader set of promise-related utilities, but it's also larger in size, which might be an overkill for projects only needing a finally functionality.
Q is another promise library that supports a .finally() method. Similar to Bluebird, Q provides a wide range of promise manipulation capabilities. It's more feature-rich than p-finally but also larger, making p-finally a lightweight alternative if the finally functionality is the main requirement.
Promise#finally()
ponyfill - Invoked when the promise is settled regardless of outcome
Useful for cleanup.
$ npm install p-finally
import pFinally from 'p-finally';
const directory = createTempDirectory();
await pFinally(write(directory), () => {
cleanup(directory);
});
Returns a Promise
.
Type: Function
Note: Throwing or returning a rejected promise will reject promise
with the rejection reason.
FAQs
`Promise#finally()` ponyfill - Invoked when the promise is settled regardless of outcome
The npm package p-finally receives a total of 19,392,338 weekly downloads. As such, p-finally popularity was classified as popular.
We found that p-finally demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Security Fundamentals
The Socket Threat Research Team uncovers how threat actors weaponize shell techniques across npm, PyPI, and Go ecosystems to maintain persistence and exfiltrate data.
Security News
At VulnCon 2025, NIST scrapped its NVD consortium plans, admitted it can't keep up with CVEs, and outlined automation efforts amid a mounting backlog.
Product
We redesigned our GitHub PR comments to deliver clear, actionable security insights without adding noise to your workflow.