Skip to content
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

Printed response body not appearing in logs until next newline is printed to stdout #15

Closed
tessellator opened this issue Feb 2, 2019 · 1 comment

Comments

@tessellator
Copy link
Contributor

When a controller is configured to print the response body, the response body will not actually appear in the logs until the next newline is printed to stdout.

The best explanation is probably an example. The following is taken from running a version of the kafka-connector built with the connector SDK with a simple function hello that returns "Hello" every time it is invoked.

 1. | 2019/02/02 05:45:33 Syncing topic map
 2. | 2019/02/02 05:45:36 Invoke function: hello
 3. | [#1] Received on [faas-request,0]: 'a'
 4. | [200] faas-request => hello
 5. | 2019/02/02 05:45:36 connector-sdk got result: [200] faas-request => hello (6) bytes
 6. | 2019/02/02 05:45:36 Syncing topic map
 7. | 2019/02/02 05:45:39 Syncing topic map
 8. | 2019/02/02 05:45:42 Syncing topic map
 9. | "Hello\n"[#2] Received on [faas-request,0]: 'b'
10. | 2019/02/02 05:45:42 Invoke function: hello
11. | 2019/02/02 05:45:42 connector-sdk got result: [200] faas-request => hello (6) bytes
12. | [200] faas-request => hello
13. | 2019/02/02 05:45:45 Syncing topic map

Line 4 is part of printing the response body, and the expected behavior is that the "Hello\n" message would be printed on the next line. However, the message is not printed until line 9. This is the next point at which a newline is printed to stdout. Note that the message for the second invocation is not printed at all.

To verify that the problem is indeed related to printing a newline to stdout, I created a ResponseSubscriber whose implementation was simply fmt.Println() and subscribed it to the controller. The result exhibits the expected behavior:

 1. | 2019/02/02 06:24:08 Syncing topic map
 2. | [#1] Received on [faas-request,0]: 'a'
 3. | 2019/02/02 06:24:09 Invoke function: hello
 4. | [200] faas-request => hello
 5. | "Hello\n"
 6. | 2019/02/02 06:24:09 connector-sdk got result: [200] faas-request => hello (6) bytes
 7. | [#2] Received on [faas-request,0]: 'b'
 8. | 2019/02/02 06:24:11 Invoke function: hello
 9. | 2019/02/02 06:24:11 connector-sdk got result: [200] faas-request => hello (6) bytes
10. | [200] faas-request => hello
11. | "Hello\n"
12. | 2019/02/02 06:24:11 Syncing topic map
@martindekov
Copy link

Hey there @tessellator nice catch there, I saw the issue you describe and it is kinda annoying. Thanks for looking into it 👍

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

No branches or pull requests

2 participants