Skip to content

Add internal delete method to functions#1687

Merged
hsubox76 merged 6 commits into
masterfrom
ch-functions
Apr 16, 2019
Merged

Add internal delete method to functions#1687
hsubox76 merged 6 commits into
masterfrom
ch-functions

Conversation

@hsubox76

Copy link
Copy Markdown
Contributor

The functions service lacks an INTERNAL.delete() method which I think is the cause of #1683. This adds a delete method which resolves a top-level promise on the service instance which should cancel any ongoing request promises.

@hsubox76 hsubox76 requested a review from bklimt April 11, 2019 22:48
Comment thread packages/functions/src/api/service.ts

@bklimt bklimt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I like the way this is implemented. Very clean. I just have a couple of questions about some details.

Comment thread packages/functions/src/api/service.ts Outdated
INTERNAL = {
delete: (): Promise<void> => {
this.deleteService();
return Promise.resolve();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fact that delete is supposed to return a Promise kind of implies to me that when the returned Promise is resolved, then the service should be finished being deleted. But that won't be the case here. this.deleteService() will have signaled the various function calls to cancel, but they won't be cancelled yet. Is that important?

It seems like it would be pretty annoying to have to implement some kind of countdown latch or something just to make sure all the functions have completed. So, what guarantees is delete supposed to make?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at Firestore and Auth, it seems like delete only guarantees that the deletion process has been started. Auth delete doesn't wait for anything before returning Promise.resolve(), Firestore shuts down some services and waits for those to complete but doesn't cancel pending promises. I don't know if this is ideal, but it's consistent for now.

Made a small change to return the result of deleteService() directly because it reads clearer, but it doesn't solve anything as far as timing.

Comment thread packages/functions/src/api/service.ts Outdated
Comment thread packages/functions/src/api/service.ts Outdated
@hsubox76 hsubox76 merged commit 780c302 into master Apr 16, 2019
@hsubox76 hsubox76 deleted the ch-functions branch April 16, 2019 18:53
@firebase firebase locked and limited conversation to collaborators Oct 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants