Skip to content

Commit 1b6847d

Browse files
authored
fix: Flush stdout and stderr streams at the end of each request (#126)
1 parent e5b9050 commit 1b6847d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/functions_framework/server.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,11 @@ def error_response message
393393
message = "Unexpected internal error" unless @config.show_error_details?
394394
string_response message, 500
395395
end
396+
397+
def flush_streams
398+
$stdout.flush
399+
$stderr.flush
400+
end
396401
end
397402

398403
## @private
@@ -415,6 +420,8 @@ def call env
415420
e
416421
end
417422
interpret_response response
423+
ensure
424+
flush_streams
418425
end
419426
end
420427

@@ -445,6 +452,8 @@ def call env
445452
raise "Unexpected event type: #{event.class}"
446453
end
447454
interpret_response response
455+
ensure
456+
flush_streams
448457
end
449458

450459
private

0 commit comments

Comments
 (0)