Skip to content

gRPC-Web requests on Safari fail when using Envoy 1.13 #10514

Closed

Description

@yoitsro

When attempting to use gRPC-Web on Safari using Envoy 1.13, the request succeeds, but in the inspector in Safari, this is the error I see:

Failed to load resource: WebKit encountered an internal error

Here's the web inspector output from Safari:

Summary

URL: https://myurl.io/svc.Authentication/Login
Status: —
Source: —
Initiator: 
2.c85f5bc6.chunk.js:2:583533

Request

Content-Type: application/grpc-web-text
Accept: application/grpc-web-text
Origin: https://my-url.com
Referer: https://my-url.com/login
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Safari/605.1.15
X-User-Agent: grpc-web-javascript/0.1
X-Grpc-Web: 1
grpc-timeout: 4999m

Response

No response headers

Request Data

MIME Type: application/grpc-web-text
Request Data: 

This issue was initially raised under the https://github.com/grpc/grpc-web repo: grpc/grpc-web#759

The request should return a successful response.

To give you more context, I'm personally running envoy via https://github.com/projectcontour/contour, though I don't think it's specific to contour since @phlippieb seems to be experiencing the same issue without contour I think.

I'm running envoy on GKE 1.15.9 as an ingress via a LoadBalancer (hence why I'm using contour).

Activity

  1. dio commented on Mar 25, 2020

    @dio
    Member

    @yoitsro sorry, does this consistently happen? Could you provide some screenshots? Thanks!

    I tried to run the grpc-web example (echotest). However, I couldn't repro this case (both for safari 12 and 13).

    image

    image

    Note the warning there is from grammarly ext that I have.

  2. yoitsro commented on Mar 25, 2020

    @yoitsro
    Author

    This does consistently happen. Here's what I see with the URLs obfuscated. If you'd like more details, let me know and we could potentially do a screen share.

    image

  3. yoitsro commented on Mar 25, 2020

    @yoitsro
    Author

    It's also worth noting that envoy is being used to terminate TLS too - I've noticed your setup is just over HTTP to localhost.

  4. added
    question
    on Mar 26, 2020
  5. eselkin commented on Mar 31, 2020

    @eselkin

    Same issue, with envoy (gloo)... managing the TLS as well with gloo.

    Safari 13.0.5
    chrome and firefox perform as expected.

  6. neno-k commented on Apr 3, 2020

    @neno-k

    are there any updates on this, we are facing the same issue after updating to istio 1.5.1, running envoy 1.13 - tested with

    safari 13.05 and 13.1

  7. vbfox commented on Apr 7, 2020

    @vbfox
    Contributor

    I have the same exact issue, also with Gloo (1.3.14) running on GKE it seem to be a crash WebKit side in their network process on queue com.apple.CFNetwork.HTTP2.HTTP2Stream triggered by some new behaviour of envoy, so while the problem is not in Envoy maybe there is a way workaround the problem envoy-side.

    I couldn't find any issue on WebKit bugzilla so I created one: https://bugs.webkit.org/show_bug.cgi?id=210108

    The crash looks like that:

    Process:               com.apple.WebKit.Networking [55694]
    Path:                  /System/Library/StagedFrameworks/Safari/WebKit.framework/Versions/A/XPCServices/com.apple.WebKit.Networking.xpc/Contents/MacOS/com.apple.WebKit.Networking
    Identifier:            com.apple.WebKit.Networking
    Version:               14608 (14608.5.12)
    Build Info:            WebKit2-7608005012000000~4
    Code Type:             X86-64 (Native)
    Parent Process:        ??? [1]
    Responsible:           Safari [55672]
    User ID:               502
    
    Date/Time:             2020-04-06 17:30:11.502 +0200
    OS Version:            Mac OS X 10.14.6 (18G3020)
    Report Version:        12
    Bridge OS Version:     4.2 (17P3050)
    Anonymous UUID:        874D8B32-6898-4020-64F8-21AA02638A09
    
    Sleep/Wake UUID:       09C3F802-395E-44B9-88C3-9D71B8E92310
    
    Time Awake Since Boot: 260000 seconds
    Time Since Wake:       16000 seconds
    
    System Integrity Protection: enabled
    
    Crashed Thread:        4  Dispatch queue: com.apple.CFNetwork.HTTP2.HTTP2Stream
    
    Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
    Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000000
    Exception Note:        EXC_CORPSE_NOTIFY
    
    Termination Signal:    Segmentation fault: 11
    Termination Reason:    Namespace SIGNAL, Code 0xb
    Terminating Process:   exc handler [55694]
    
    VM Regions Near 0:
    --> 
        __TEXT                 000000010faea000-000000010faeb000 [    4K] r-x/rwx SM=COW  /System/Library/StagedFrameworks/Safari/WebKit.framework/Versions/A/XPCServices/com.apple.WebKit.Networking.xpc/Contents/MacOS/com.apple.WebKit.Networking
    
    Thread 0:: Dispatch queue: com.apple.main-thread
    0   libsystem_kernel.dylib        	0x00007fff5899421a mach_msg_trap + 10
    1   libsystem_kernel.dylib        	0x00007fff58994768 mach_msg + 60
    2   com.apple.CoreFoundation      	0x00007fff2c8d499e __CFRunLoopServiceMachPort + 328
    3   com.apple.CoreFoundation      	0x00007fff2c8d3f0c __CFRunLoopRun + 1612
    4   com.apple.CoreFoundation      	0x00007fff2c8d366e CFRunLoopRunSpecific + 455
    5   com.apple.Foundation          	0x00007fff2eb392ff -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 280
    6   com.apple.Foundation          	0x00007fff2eb391d4 -[NSRunLoop(NSRunLoop) run] + 76
    7   libxpc.dylib                  	0x00007fff58a9805b _xpc_objc_main + 552
    8   libxpc.dylib                  	0x00007fff58a97b5d xpc_main + 433
    9   com.apple.WebKit              	0x000000010fccfeb1 WebKit::XPCServiceMain(int, char const**) + 547
    10  libdyld.dylib                 	0x00007fff5885f3d5 start + 1
    
    Thread 1:: JavaScriptCore bmalloc scavenger
    0   libsystem_kernel.dylib        	0x00007fff58997866 __psynch_cvwait + 10
    1   libsystem_pthread.dylib       	0x00007fff58a5656e _pthread_cond_wait + 722
    2   libc++.1.dylib                	0x00007fff55a90b31 std::__1::condition_variable::__do_timed_wait(std::__1::unique_lock<std::__1::mutex>&, std::__1::chrono::time_point<std::__1::chrono::system_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >) + 93
    3   com.apple.JavaScriptCore      	0x0000000115110ec6 bmalloc::Scavenger::threadRunLoop() + 774
    4   com.apple.JavaScriptCore      	0x0000000115110889 bmalloc::Scavenger::threadEntryPoint(bmalloc::Scavenger*) + 9
    5   com.apple.JavaScriptCore      	0x0000000115113097 void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)(bmalloc::Scavenger*), bmalloc::Scavenger*> >(void*) + 39
    6   libsystem_pthread.dylib       	0x00007fff58a532eb _pthread_body + 126
    7   libsystem_pthread.dylib       	0x00007fff58a56249 _pthread_start + 66
    8   libsystem_pthread.dylib       	0x00007fff58a5240d thread_start + 13
    
    Thread 2:: com.apple.NSURLConnectionLoader
    0   libsystem_kernel.dylib        	0x00007fff5899421a mach_msg_trap + 10
    1   libsystem_kernel.dylib        	0x00007fff58994768 mach_msg + 60
    2   com.apple.CoreFoundation      	0x00007fff2c8d499e __CFRunLoopServiceMachPort + 328
    3   com.apple.CoreFoundation      	0x00007fff2c8d3f0c __CFRunLoopRun + 1612
    4   com.apple.CoreFoundation      	0x00007fff2c8d366e CFRunLoopRunSpecific + 455
    5   com.apple.CFNetwork           	0x00007fff2b7b8078 -[__CoreSchedulingSetRunnable runForever] + 210
    6   com.apple.Foundation          	0x00007fff2eb2f0e2 __NSThread__start__ + 1194
    7   libsystem_pthread.dylib       	0x00007fff58a532eb _pthread_body + 126
    8   libsystem_pthread.dylib       	0x00007fff58a56249 _pthread_start + 66
    9   libsystem_pthread.dylib       	0x00007fff58a5240d thread_start + 13
    
    Thread 3:
    0   libsystem_pthread.dylib       	0x00007fff58a523f0 start_wqthread + 0
    
    Thread 4 Crashed:: Dispatch queue: com.apple.CFNetwork.HTTP2.HTTP2Stream
    0   com.apple.CoreFoundation      	0x00007fff2c8b1b6e CFArrayGetCount + 10
    1   com.apple.CFNetwork           	0x00007fff2b7e5269 HTTP2Stream::_onqueue_processRawHeaders() + 45
    2   com.apple.CFNetwork           	0x00007fff2b91bc4a HTTP2Stream::_onqueue_endTrailers() + 18
    3   libdispatch.dylib             	0x00007fff588115f8 _dispatch_call_block_and_release + 12
    4   libdispatch.dylib             	0x00007fff5881263d _dispatch_client_callout + 8
    5   libdispatch.dylib             	0x00007fff588188e0 _dispatch_lane_serial_drain + 602
    6   libdispatch.dylib             	0x00007fff58819396 _dispatch_lane_invoke + 385
    7   libdispatch.dylib             	0x00007fff588216ed _dispatch_workloop_worker_thread + 598
    8   libsystem_pthread.dylib       	0x00007fff58a52611 _pthread_wqthread + 421
    9   libsystem_pthread.dylib       	0x00007fff58a523fd start_wqthread + 13
    
    Thread 5:: WebCore: AsyncFileStream
    0   libsystem_kernel.dylib        	0x00007fff58997866 __psynch_cvwait + 10
    1   libsystem_pthread.dylib       	0x00007fff58a5656e _pthread_cond_wait + 722
    2   com.apple.JavaScriptCore      	0x000000011509f217 WTF::ParkingLot::parkConditionallyImpl(void const*, WTF::ScopedLambda<bool ()> const&, WTF::ScopedLambda<void ()> const&, WTF::TimeWithDynamicClockType const&) + 3927
    3   com.apple.WebCore             	0x0000000110e275b5 bool WTF::Condition::waitUntil<WTF::Lock>(WTF::Lock&, WTF::TimeWithDynamicClockType const&) + 165
    4   com.apple.WebCore             	0x00000001111f8f83 std::__1::unique_ptr<WTF::Function<void ()>, std::__1::default_delete<WTF::Function<void ()> > > WTF::MessageQueue<WTF::Function<void ()> >::waitForMessageFilteredWithTimeout<WTF::MessageQueue<WTF::Function<void ()> >::waitForMessage()::'lambda'(WTF::Function<void ()> const&)>(WTF::MessageQueueWaitResult&, WTF::MessageQueue<WTF::Function<void ()> >::waitForMessage()::'lambda'(WTF::Function<void ()> const&)&&, WTF::Seconds) + 211
    5   com.apple.WebCore             	0x0000000111ea546d WebCore::callOnFileThread(WTF::Function<void ()>&&)::$_9::operator()() const::'lambda'()::operator()() const + 93
    6   com.apple.WebCore             	0x0000000111ea5409 WTF::Detail::CallableWrapper<WebCore::callOnFileThread(WTF::Function<void ()>&&)::$_9::operator()() const::'lambda'(), void>::call() + 9
    7   com.apple.JavaScriptCore      	0x00000001150b87c3 WTF::Thread::entryPoint(WTF::Thread::NewThreadContext*) + 403
    8   com.apple.JavaScriptCore      	0x00000001150bb379 WTF::wtfThreadEntryPoint(void*) (.llvm.12532219493473948909) + 9
    9   libsystem_pthread.dylib       	0x00007fff58a532eb _pthread_body + 126
    10  libsystem_pthread.dylib       	0x00007fff58a56249 _pthread_start + 66
    11  libsystem_pthread.dylib       	0x00007fff58a5240d thread_start + 13
    
    Thread 6:: IndexedDatabase Server
    0   libsystem_kernel.dylib        	0x00007fff58997866 __psynch_cvwait + 10
    1   libsystem_pthread.dylib       	0x00007fff58a5656e _pthread_cond_wait + 722
    2   com.apple.JavaScriptCore      	0x000000011509f217 WTF::ParkingLot::parkConditionallyImpl(void const*, WTF::ScopedLambda<bool ()> const&, WTF::ScopedLambda<void ()> const&, WTF::TimeWithDynamicClockType const&) + 3927
    3   com.apple.JavaScriptCore      	0x0000000114a8b545 bool WTF::Condition::waitUntil<WTF::Lock>(WTF::Lock&, WTF::TimeWithDynamicClockType const&) + 165
    4   com.apple.JavaScriptCore      	0x000000011507cb3e WTF::Detail::CallableWrapper<WTF::CrossThreadTaskHandler::CrossThreadTaskHandler(char const*, WTF::CrossThreadTaskHandler::AutodrainedPoolForRunLoop)::$_0, void>::call() + 302
    5   com.apple.JavaScriptCore      	0x00000001150b87c3 WTF::Thread::entryPoint(WTF::Thread::NewThreadContext*) + 403
    6   com.apple.JavaScriptCore      	0x00000001150bb379 WTF::wtfThreadEntryPoint(void*) (.llvm.12532219493473948909) + 9
    7   libsystem_pthread.dylib       	0x00007fff58a532eb _pthread_body + 126
    8   libsystem_pthread.dylib       	0x00007fff58a56249 _pthread_start + 66
    9   libsystem_pthread.dylib       	0x00007fff58a5240d thread_start + 13
    
    Thread 7:
    0   libsystem_pthread.dylib       	0x00007fff58a523f0 start_wqthread + 0
    
    Thread 8:: Dispatch queue: com.apple.CFNetwork.Connection
    0   libobjc.A.dylib               	0x00007fff57086bbe -[NSObject autorelease] + 20
    1   com.apple.LaunchServices      	0x00007fff2ded3769 -[_UTTypeQuery resolve] + 76
    2   com.apple.LaunchServices      	0x00007fff2ded5649 UTTypeCopyAllTagsWithClass + 116
    3   com.apple.LaunchServices      	0x00007fff2ded5591 UTTypeCopyPreferredTagWithClass + 12
    4   com.apple.CFNetwork           	0x00007fff2b7e2d8e copyMIMETypeForExtension + 65
    5   com.apple.CFNetwork           	0x00007fff2b7e2cfe +[NSURLSessionTaskDependencyTree mimeTypeForURLString:] + 55
    6   com.apple.CFNetwork           	0x00007fff2b7e6968 -[__NSCFURLSessionTaskActiveStreamDependencyInfo removeStreamWithStreamID:requestURLString:] + 242
    7   com.apple.CFNetwork           	0x00007fff2b7e6799 __NSURLSessionTaskDependency_RemoveRequest + 135
    8   com.apple.CFNetwork           	0x00007fff2b7e66a8 HTTP2Stream::cleanUpInUserDataResetCallback(nghttp2_session*, int, unsigned int, HTTP2Connection*) + 90
    9   com.apple.CFNetwork           	0x00007fff2b7e6616 cf_nghttp2_on_stream_close_callback(nghttp2_session*, int, unsigned int, void*) + 111
    10  libapple_nghttp2.dylib        	0x00007fff558ddacd nghttp2_session_close_stream + 147
    11  libapple_nghttp2.dylib        	0x00007fff558db5e4 nghttp2_session_mem_recv + 8010
    12  libapple_nghttp2.dylib        	0x00007fff558d9621 nghttp2_session_recv + 98
    13  com.apple.CFNetwork           	0x00007fff2b7e3f1b HTTP2Connection::_onqueue_performRead() + 21
    14  com.apple.CFNetwork           	0x00007fff2b7e3167 HTTP2Connection::_onqueue_scheduleIO() + 153
    15  libdispatch.dylib             	0x00007fff588115f8 _dispatch_call_block_and_release + 12
    16  libdispatch.dylib             	0x00007fff5881263d _dispatch_client_callout + 8
    17  libdispatch.dylib             	0x00007fff588188e0 _dispatch_lane_serial_drain + 602
    18  libdispatch.dylib             	0x00007fff588193c6 _dispatch_lane_invoke + 433
    19  libdispatch.dylib             	0x00007fff5881a667 _dispatch_workloop_invoke + 2100
    20  libdispatch.dylib             	0x00007fff588216ed _dispatch_workloop_worker_thread + 598
    21  libsystem_pthread.dylib       	0x00007fff58a52611 _pthread_wqthread + 421
    22  libsystem_pthread.dylib       	0x00007fff58a523fd start_wqthread + 13
    
    Thread 4 crashed with X86 Thread State (64-bit):
      rax: 0x0000000000000001  rbx: 0x00007fd3df564dc0  rcx: 0x00000000000001b1  rdx: 0x00007fff8efc1388
      rdi: 0x0000000000000000  rsi: 0x00007fff588115ec  rbp: 0x000070000c6948a0  rsp: 0x000070000c6948a0
       r8: 0x00000000840f4000   r9: 0x00007fd3df5270e0  r10: 0x0000000000000004  r11: 0x0000000000000004
      r12: 0x0000000000000000  r13: 0x0000000000000000  r14: 0x00007fd3e9022cf0  r15: 0x0000000118a02880
      rip: 0x00007fff2c8b1b6e  rfl: 0x0000000000010246  cr2: 0x0000000000000000
      
    Logical CPU:     10
    Error Code:      0x00000004
    Trap Number:     14
    
  8. added
    investigate
    and removed
    question
    on Apr 7, 2020
  9. mattklein123 commented on Apr 7, 2020

    @mattklein123
    Member
  10. vbfox commented on Apr 8, 2020

    @vbfox
    Contributor

    Someone responded on WebKit bugzilla that the problem is not inside WebKit but on a lower level library & now tracked Apple side in Radar as rdar://problem/61383605 (If anyone wants to reference it with them)

  11. stale commented on May 9, 2020

    @stale

    This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or other activity occurs. Thank you for your contributions.

  12. added
    stale
    on May 9, 2020
  13. mrtrkmn commented on May 12, 2020

    @mrtrkmn

    It does not have any problem regarding to version v1.12.0. I am noting it down here, if any of you would like to have quick solution, until the bug fixed.

  14. 16 remaining items

  15. dio commented on Jul 20, 2020

    @dio
    Member

    Seems like skipping trailers.clear() for HTTP/2 could help this. @yoitsro could you try my image: dio123/envoy:grpc-web-debug (note that this one is ubuntu-based, not the alpine one)? From my local testing here, it seems to be working (I could reproduce this issue using the latest release).

    Basically, the following:

      if (encoder_callbacks_->streamInfo().protocol().value() != Http::Protocol::Http2) {
        // Clear out the trailers so they don't get added since it is now in the body
        trailers.clear();
      }
  16. yoitsro commented on Jul 20, 2020

    @yoitsro
    Author

    I can confirm that this is working :tears_of_joy:

  17. yoitsro commented on Jul 20, 2020

    @yoitsro
    Author

    Is there anything I/we can do to help get this released?

  18. dio commented on Jul 20, 2020

    @dio
    Member

    @yoitsro sorry for the late reply, but I have submitted a PR: #12178.

  19. self-assigned this
    on Jul 20, 2020
  20. added and removed
    investigate
    on Jul 27, 2020
  21. added this to the 1.16.0 milestone on Jul 27, 2020
  22. added
    no stalebot
    on Jul 27, 2020
  23. added a commit that references this issue on Aug 5, 2020
    7d03b62
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/grpcbugno stalebot

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions