fix(backend): NSFW検出モデルが file:// で読み込めない問題を修正 (tfjs-node external化後の tfjs-core 分裂)#17528
Merged
kakkokari-gtyih merged 1 commit intoJun 2, 2026
Conversation
misskey-dev#17501 で `@tensorflow/tfjs-node` を bundle 外に出した結果、bundle 内の `nsfwjs` が抱える `@tensorflow/tfjs-core` と external な tfjs-node が使う tfjs-core が別インスタンスに分裂し、tfjs-node が登録する `file://` IOHandler を nsfwjs 側が共有できなくなった。このため nsfwjs のモデル読み込みが HTTP handler (node-fetch) にフォールバックし `URL scheme "file" is not supported` で失敗する。 `nsfwjs` と `@tensorflow/*` も external 化し、単一の tfjs-core インスタンスに 統一することで file:// IOHandler を共有させる。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
file:// after externalizing tfjs-node (#17527)file:// で読み込めない問題を修正 (tfjs-node external化後の tfjs-core 分裂)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #17528 +/- ##
===========================================
+ Coverage 15.22% 24.91% +9.68%
===========================================
Files 247 1160 +913
Lines 12349 39562 +27213
Branches 4196 11013 +6817
===========================================
+ Hits 1880 9856 +7976
- Misses 8196 23804 +15608
- Partials 2273 5902 +3629 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
|
このPRによるapi.jsonの差分 |
Contributor
Backend memory usage comparisonBefore GC
After GC
After Request
|
sasagar
added a commit
to ikaskey/misskey
that referenced
this pull request
Jun 2, 2026
NSFW 検出モデルが file:// で読み込めない問題の修正 (cherry-pick) を含む。 upstream: misskey-dev#17528 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Member
|
🙏 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
packages/backend/rolldown.config.tsでnsfwjsと@tensorflow/*ファミリ全体を external 化します (これまでは@tensorflow/tfjs-nodeのみ external)。Fixes #17527.
Why
#17501 で
@tensorflow/tfjs-nodeをバンドル外に出して以降、センシティブメディア検出 (NSFW) が以下のエラーで壊れていました。@tensorflow/tfjs-nodeはfile://のIOHandlerを 自身が参照する@tensorflow/tfjs-coreに登録します。しかしnsfwjs(とその依存の@tensorflow/tfjs→@tensorflow/tfjs-core) はバンドル内に残っていたため、実行時にtfjs-coreのインスタンスが 2 つに分裂 していました。nsfwjs.load()はfile://router を持たないバンドル内tfjs-core上で動き、HTTP ハンドラ →AiServiceが差し込んだnode-fetchにフォールバックしてfile://が拒否されます。nsfwjsと@tensorflow/*を external 化することで TF.js スタック全体が単一の dedupe 済み@tensorflow/tfjs-core(いずれも4.22.0) に解決され、tfjs-nodeが登録したfile://IOHandler が共有されます。根本原因の詳細は #17527 を参照してください。バンドルへの影響はありません。
packages/backend/src内でのこれらのモジュールの参照はimport type(ビルド時に消去) とawait import(...)(動的) のみで、バンドルが静的に import している箇所は無いため、これらは既に external な@tensorflow/tfjs-nodeと同様にnode_modulesから解決される実行時requireになるだけです。Additional info (optional)
稼働中の
2026.5.4インスタンス (Node 22.22.2 /develop+ #17068 + #17501 ビルド) で検証しました。[2] は修正後の解決経路 (
nsfwjsを external 解決 → 単一tfjs-coreを共有) をそのまま再現し、file://でのモデル読み込みが復活することを確認しています。ローカルでのフルバンドル再ビルドは未実施ですが、バンドルビルド自体は CI で検証され、本変更は既存のexternalModules配列にエントリを追加するのみ (@sentry/@napi-rs/slaccで既に使われているRegExp形式と同じ) です。Checklist