Skip to content

Add auto-flushing to middleware integration #2017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 17, 2019
Merged

Conversation

sheerun
Copy link
Contributor

@sheerun sheerun commented Apr 11, 2019

As per request I send PR implementing #2001

I've checked manually that it indeed flushes errors before request finishes if { wait: true } is used

  • If you've added code that should be tested, please add tests.
    Unfortunately there's no testing scaffold for existing code so it's hard for me to add new

@sheerun sheerun requested a review from kamilogorek as a code owner April 11, 2019 16:47

res.end = async function end (chunk?: any, encodingOrCb?: string | Function, cb?: Function) {
await flush(2000)
console.log('flushed')
Copy link
Contributor

Choose a reason for hiding this comment

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

debug leftovers?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry I've already removed it

@@ -221,12 +222,21 @@ export function requestHandler(options?: {
transaction?: boolean | TransactionTypes;
user?: boolean | string[];
version?: boolean;
wait?: boolean;
Copy link
Member

Choose a reason for hiding this comment

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

Can we make this number | undefined instead of a boolean and rename it to flushTimeout.
Also, use flushTimeout then instead of the hardcoded 2000.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

then maybe make it number and let 0 be the default which means "no flush"?

Copy link
Member

Choose a reason for hiding this comment

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

this would also work

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've updated the code

Copy link
Member

@HazAT HazAT left a comment

Choose a reason for hiding this comment

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

Cool stuff, thx 🥇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants