显然,你需要逃跑
admin.app().delete();
,否则与Firebase的连接将保持活动状态,从而阻止进程终止。
因此,在我的示例代码中,考虑到在运行此函数后,我将不再需要使用Firebase:
public getUser(uid: string): any {
console.log('FirebaseManager getUser method start');
const self: FirebaseManager = this;
const promise: any = self.getDeferred();
admin.auth().getUser(uid)
.then(function(userRecord: admin.auth.UserRecord) {
console.log("Successfully fetched user data:", userRecord);
admin.app().delete();
promise.resolve(userRecord);
})
.catch(function(error: FirebaseError) {
console.log("Error fetching user data:", error.errorInfo);
admin.app().delete();
promise.reject('Error getting Firebase user ' + uid);
});
return promise.promise;
}