Open2
MikroORMとfastifyの組み合わせでエラーが出るとき

今回起きたこと
MikroORM の RequestContext を利用して EntityManager をリクエストごとに fork するようにしていたけれど、ハンドラーの途中から以下のエラーを MikroORM が投げるようになってしまった。
ValidationError: Using global EntityManager instance methods for context specific actions is disallowed. If you need to work with the global instance's identity map, use `allowGlobalContext` configuration option or `fork()` instead.

原因はよくわかってないけれど解決策?
を参考に @fastify/request-context
を用いて fork した EntityManager を保存しておく方法を試したところうまく動いてくれるようになった。