getSession: an unhandled rejection of bufferOrPathPromise ends Node when an external data download fails
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- javascript, node.js
- Domain
- backend, machine-learning
Research direction
Read packages/transformers/src/models/session.js around lines 93–126, where getCoreModelFile(...) and getModelDataFiles(...) are awaited. Reproduce with the issue’s cached model files and dtype: 'fp32' against an unavailable remote host. Done when the caller’s try/catch handles the download failure and the Node process reaches the end normally; the issue gives no test file to run.
Written by the indexing model from the issue text.
Description
System Info
@huggingface/transformers4.3.2 (dist/transformers.node.mjs). The same code is onmainat 205e9c251162: session.js#L93-L126- Node.js 22.23.5 and 26.13.0, Windows 11
Environment/Platform
- Server-side (e.g., Node.js, Deno, Bun)
Description
getSession starts getCoreModelFile(...) and keeps the promise in bufferOrPathPromise (L93). It then awaits getModelDataFiles(...) (L97) and awaits bufferOrPathPromise only at L126. When getModelDataFiles rejects, getSession exits before L126. The rejection of bufferOrPathPromise then has no handler. Node reports an unhandled rejection and ends the process with exit code 1. The caller's try/catch around pipeline() does not prevent the exit.
It needs a dtype whose model uses external data (use_external_data_format), so that getModelDataFiles fetches something. With dtype: 'q8' on the same model, the error is caught normally.
Reproduction
- Cache only the JSON files of
onnx-community/Qwen3-Embedding-0.6B-ONNX(config.json,tokenizer.json,tokenizer_config.json) underenv.cacheDir. Leaveonnx/absent. - Run:
import { env, pipeline } from '@huggingface/transformers';
env.cacheDir = './cache/';
env.remoteHost = 'http://127.0.0.1:59999/'; // a closed port
try {
await pipeline('feature-extraction', 'onnx-community/Qwen3-Embedding-0.6B-ONNX', { dtype: 'fp32' });
} catch (e) {
console.log('CAUGHT:', e.message);
}
console.log('reached end of script');
Expected: CAUGHT: fetch failed, then reached end of script, exit code 0.
Observed (exit code 1, no CAUGHT line):
node:internal/process/promises:324
triggerUncaughtException(err, true /* fromPromise */);
^
[TypeError: fetch failed] {
[cause]: Error: connect ECONNREFUSED 127.0.0.1:59999
dtype: 'fp16' gives the same result. Node 22 gives the same exit code.
Control: with bufferOrPathPromise.catch(() => {}); added after L93 in dist/transformers.node.mjs, the same script prints CAUGHT: fetch failed and reached end of script, and exits 0.
Suggested fix
Attach a handler when the promise is created, and keep the await at L126:
const bufferOrPathPromise = getCoreModelFile(...); bufferOrPathPromise.catch(() => {});
Or await both together: Promise.all([getCoreModelFile(...), getModelDataFiles(...)]).
Related: #1801 and #1804 fixed a failure of an external data download in model-loader.js. This one is in session.js.
- Dominant language
- JavaScript
- Stars
- 16.4k
- Forks
- 1.2k
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 10
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from huggingface/transformers.js
-
wav2vec2 ASR drops repeated letters ("slipper" → "sliper"): blank tokens are skipped before CTC merges repeatsPossibly taken @chessing234 claimed this 3 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
huggingface/transformers.js#1947 ·
Maintainers usually reply within 1 day
-
Expose the browser build as a subpath export (./dist/transformers.web.js)Possibly taken @anshusaurav claimed this 4 days ago. Open
Difficulty 1/5 Under an hour Newbie friendliness 88/100
huggingface/transformers.js#1945 · 1 comment ·
Maintainers usually reply within 1 day
-
TextStreamer drops apostrophes with WordPiece tokenizers (clean_up_tokenization_spaces)Possibly taken @erdemozkan claimed this 7 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
huggingface/transformers.js#1940 ·
Maintainers usually reply within 1 day
-
Image processors with shortest_edge + longest_edge upscale every image to longest_edge (DETR, YOLOS)May be free again A pull request for this issue was closed without being merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
huggingface/transformers.js#1886 · 1 comment ·
Maintainers usually reply within 1 day
-
RawImage.resize in Node (sharp affine) darkens image borders: a uniform image does not stay uniformMay be free again A pull request for this issue was closed without being merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
huggingface/transformers.js#1885 · 1 comment ·
Maintainers usually reply within 1 day
All issues in huggingface/transformers.js
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
speakeasy-api/speakeasy#2159 ·
Maintainers usually reply within 1 day
-
Queued deferred selectors still run after unmountPossibly taken @LexaTang claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
ianstormtaylor/slate#6375 ·
Maintainers usually reply within 1 day
-
sync cache dist/imgOpen
Difficulty 1/5 Under an hour Newbie friendliness 82/100
oleeskild/digitalgarden#435 ·