Callable 리전을 서울로 고정하는 부트스트랩을 함수 정의보다 먼저 · 에뮬레이터 연결이 목 모드로 내려가지 않게
This commit is contained in:
@@ -92,20 +92,36 @@ abstract final class FirebaseBoot {
|
||||
|
||||
static Future<void> _initEmulator() async {
|
||||
try {
|
||||
await Firebase.initializeApp(options: _emulatorOptions);
|
||||
// **이미 초기화된 앱이 있으면 그것을 쓴다.** Android 는 `google-services.json` 이
|
||||
// 있으면 네이티브 SDK 가 앱이 뜰 때 `[DEFAULT]` 를 만들어 둔다. 그 자리에 다시
|
||||
// 만들면 `duplicate-app` 으로 떨어지고, 예외를 삼키던 이 경로가 **조용히 목 모드로**
|
||||
// 내려간다 — 에뮬레이터를 물린 줄 알고 도는 확인이 전부 무의미해진다.
|
||||
//
|
||||
// `Firebase.apps` 로는 미리 알 수 없다. 네이티브가 만든 앱은 Dart 쪽 목록에
|
||||
// 아직 올라와 있지 않아서, 만들어 보고 걸리면 그때 집는다.
|
||||
try {
|
||||
await Firebase.initializeApp(options: _emulatorOptions);
|
||||
} on FirebaseException catch (error) {
|
||||
if (error.code != 'duplicate-app') rethrow;
|
||||
}
|
||||
FirebaseAuth.instance.useAuthEmulator(emulatorHost, 9099);
|
||||
FirebaseFirestore.instance.useFirestoreEmulator(emulatorHost, 8080);
|
||||
FirebaseFunctions.instanceFor(region: Backend.region)
|
||||
.useFunctionsEmulator(emulatorHost, 5001);
|
||||
_mode = FirebaseMode.live;
|
||||
_reason = '로컬 에뮬레이터에 연결했습니다. 실 서버가 아닙니다.';
|
||||
_detail = 'emulator host: $emulatorHost';
|
||||
// 설정 파일이 있는 빌드에서는 프로젝트 ID 가 실 프로젝트 그대로다. 에뮬레이터는
|
||||
// 프로젝트 ID 별로 칸을 나누므로, 시드를 넣을 때 같은 ID 를 써야 한다.
|
||||
_detail = 'emulator host: $emulatorHost · project: ${Firebase.app().options.projectId}';
|
||||
} on Object catch (error) {
|
||||
_mode = FirebaseMode.mock;
|
||||
_reason = '에뮬레이터에 연결하지 못해 임시(목) 모드로 동작 중입니다.';
|
||||
_detail = '원인: $error';
|
||||
}
|
||||
debugPrint('[FirebaseBoot] mode=${_mode.name} :: $_reason');
|
||||
// 사유를 함께 남긴다. 이 경로가 조용히 목 모드로 내려가면 「에뮬레이터를 물렸다고
|
||||
// 믿고 도는 확인」이 되므로, 원인이 로그에 없으면 찾는 데만 한참 걸린다.
|
||||
if (_detail != null) debugPrint('[FirebaseBoot] detail :: $_detail');
|
||||
}
|
||||
|
||||
/// 테스트에서 모드를 고정할 때만 쓴다.
|
||||
|
||||
Reference in New Issue
Block a user