Skip to content

feat: explicit resource management#141

Open
xbwwj wants to merge 1 commit into
sqdshguy:masterfrom
xbwwj:feat/explicit
Open

feat: explicit resource management#141
xbwwj wants to merge 1 commit into
sqdshguy:masterfrom
xbwwj:feat/explicit

Conversation

@xbwwj

@xbwwj xbwwj commented May 24, 2026

Copy link
Copy Markdown

Add explicit resource management, so that users can use using statement instead of boilerplate and forgettable try-finally:

import { createSession } from 'wreq-js';

// original try-finally
const session = await createSession({ browser: 'chrome_142', os: 'windows' });
try {
  await session.fetch('https://example.com/a');
} finally {
  await session.close();
}

// with EMR using statement
await using session = await createSession({ browser: 'chrome_142', os: 'windows' });
await session.fetch('https://example.com/a');

I'm not sure if tests are required as using is just a syntax sugar around the .close() method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant