SSR => @firebase/auth: Auth (9.6.8): INTERNAL ASSERTION FAILED: Expected a class definition
- Ngôn ngữ chính
- TypeScript
- Star
- 7.8k
- Fork
- 2.2k
- Merge trung bình
- 22 giờ 28 phút
- Pull request đã merge (30 ngày)
- 6
Mô tả
**Firebase:**
```
"firebase": "^9.6.8",
```
**AngularFire:**
```
Angular CLI: 13.3.0
Node: 14.16.0
Package Manager: npm 6.14.11
OS: darwin x64
Angular: 13.2.5
... animations, cdk, common, compiler, compiler-cli, core, forms
... language-service, material, platform-browser
... platform-browser-dynamic, platform-server, router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1303.0
@angular-devkit/build-angular 13.0.4
@angular-devkit/core 13.3.0
@angular-devkit/schematics 13.3.0
@angular/cli 13.3.0
@angular/fire 7.2.1
@angular/google-maps 13.3.0
@nguniversal/builders 13.0.2
@nguniversal/express-engine 13.0.2
@schematics/angular 13.3.0
ng-packagr 13.2.1
rxjs 6.6.7
typescript 4.5.5
```
### How to reproduce these conditions
1. ```run habitat-commons:serve-ssr:development```
2. in my app browser and ssr server will build fine
3. start ssr server `node dist/apps/habitat-commons/server/main.js`
4. make a request to this server
5. see errors below
### First Error
```
@firebase/auth: Auth (9.6.8): INTERNAL ASSERTION FAILED: Expected a class definition
Error: INTERNAL ASSERTION FAILED: Expected a class definition
at debugFail (test_app/dist/apps/habitat-commons/server/main.js:317691:9)
at debugAssert (test_app/dist/apps/habitat-commons/server/main.js:317704:5)
at Module._getInstance (test_app/dist/apps/habitat-commons/server/main.js:317728:3)
at new CompatPopupRedirectResolver (test_app/dist/apps/habitat-commons/server/main.js:315880:81)
at _getInstance (test_app/dist/apps/habitat-commons/server/main.js:317736:14)
at AuthImpl._initializeWithPersistence (test_app/dist/apps/habitat-commons/server/main.js:320082:37)
at _initializeAuthInstance (test_app/dist/apps/habitat-commons/server/main.js:317817:8)
at test_app/dist/apps/habitat-commons/server/main.js:325294:7
at Component.instanceFactory (test_app/dist/apps/habitat-commons/server/main.js:325297:7)
at Provider.getOrInitializeService (test_app/dist/apps/habitat-commons/server/main.js:327833:33)
```
i looked into the `_getInstance` mentioned in the callstack. it takes an arg that should be a class instance. _hence the error._
Here is what `_getInstance` looked like in my ssr bootstrap (`main.js`)
```
function _getInstance(cls) {
console.log('**((_getInstance 0))**', cls)
debugAssert(cls instanceof Function, 'Expected a class definition');
let instance = instanceCache.get(cls);
if (instance) {
debugAssert(instance instanceof cls, 'Instance stored in cache mismatched with class');
return instance;
}
instance = new cls();
instanceCache.set(cls, instance);
return instance;
}
```
The log i added(see above) revealed that an error instead of a class was passed in the 3 rd time.see out put below
```
**((_getInstance 0))** [class InMemoryPersistence] { type: 'NONE' }
**((_getInstance 0))** [class CompatPopupRedirectResolver]
**((_getInstance 0))** FirebaseError: Firebase: Error (auth/operation-not-supported-in-this-environment).
at createErrorInternal (test_app/dist/apps/habitat-commons/server/main.js:317665:38)
at _createError (test_app/dist/apps/habitat-commons/server/main.js:317640:10)
at Module.2485 (test_app/dist/apps/habitat-commons/server/main.js:325381:29)
at __webpack_require__ (test_app/dist/apps/habitat-commons/server/main.js:545206:42)
at Module.32562 (test_app/dist/apps/habitat-commons/server/main.js:325547:76)
at __webpack_require__ (test_app/dist/apps/habitat-commons/server/main.js:545206:42)
at Module.70092 (test_app/dist/apps/habitat-commons/server/main.js:315550:81)
at __webpack_require__ (test_app/dist/apps/habitat-commons/server/main.js:545206:42)
at Module.55776 (test_app/dist/apps/habitat-commons/server/main.js:500158:79)
at __webpack_require__ (test_app/dist/apps/habitat-commons/server/main.js:545206:42) {
code: 'auth/operation-not-supported-in-this-environment',
customData: {}
}
[2022-03-17T20:12:59.002Z] @firebase/auth: Auth (9.6.8): INTERNAL ASSERTION FAILED: Expected a class definition
ERROR Error: INTERNAL ASSERTION FAILED: Expected a class definition
```
of course all my servers and test requests are on local host...Do you know anything that can help me understand either error
> @firebase/auth: Auth (9.6.8): INTERNAL ASSERTION FAILED: Expected a class definition
or
> Firebase: Error (auth/operation-not-supported-in-this-environment)
### Expected behavior
I expected to send a universal rendered view to the browser
### Actual behavior
Firebase auth prevents universal from performing its task.
Hướng dẫn đóng góp
Hướng nghiên cứu
Tái hiện sự cố với `habitat-commons:serve-ssr:development`, sau đó khởi động `dist/apps/habitat-commons/server/main.js` và gửi một request. Kiểm tra stack bootstrap SSR xung quanh `_getInstance` trong `main.js` được tạo, sử dụng các phiên bản và lỗi Firebase Auth đã được báo cáo làm điểm bắt đầu. Hoàn thành khi server xử lý request mà không có các assertion của Firebase Auth và trả về view được render universal như mong đợi.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- angular, firebase, typescript
- Lĩnh vực
- authentication
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 35/100