File tree Expand file tree Collapse file tree 2 files changed +49
-1
lines changed Expand file tree Collapse file tree 2 files changed +49
-1
lines changed Original file line number Diff line number Diff line change @@ -160,7 +160,9 @@ private function beginInstantTransaction(
160
160
private function acquireConnection (TransactionConfiguration $ config , SessionConfiguration $ sessionConfig ): BoltConnection
161
161
{
162
162
$ connection = $ this ->pool ->acquire ($ this ->uri , $ this ->auth , $ sessionConfig );
163
- $ connection ->setTimeout ($ config ->getTimeout ());
163
+ // We try and let the server do the timeout management.
164
+ // Since the client should not run indefinitely, we just multiply the client side by two, just in case
165
+ $ connection ->setTimeout ($ config ->getTimeout () * 2 );
164
166
165
167
return $ connection ;
166
168
}
Original file line number Diff line number Diff line change @@ -376,6 +376,52 @@ public function testLongQueryUnmanaged(string $alias): void
376
376
$ tsx ->run ('CALL apoc.util.sleep(10000) ' );
377
377
}
378
378
379
+ /**
380
+ * @dataProvider connectionAliases
381
+ */
382
+ public function testSimpleTimeout (string $ alias ): void
383
+ {
384
+ if (str_starts_with ($ alias , 'http ' )) {
385
+ self ::markTestSkipped ('Http does not support timeouts at the moment ' );
386
+ }
387
+
388
+ try {
389
+ $ this ->getClient ()
390
+ ->getDriver ($ alias )
391
+ ->createSession ()
392
+ ->run (
393
+ "MATCH (n:Node) SET n.testing = 'hello' WITH * CALL apoc.util.sleep(2000000) " ,
394
+ [],
395
+ TransactionConfiguration::default ()->withTimeout (10 )
396
+ );
397
+ } catch (Neo4jException $ e ) {
398
+ self ::assertEquals ('Neo.ClientError.Transaction.TransactionTimedOut ' , $ e ->getNeo4jCode ());
399
+ }
400
+ }
401
+
402
+ /**
403
+ * @dataProvider connectionAliases
404
+ */
405
+ public function testDiscardAfterTimeout (string $ alias ): void
406
+ {
407
+ if (str_starts_with ($ alias , 'http ' )) {
408
+ self ::markTestSkipped ('Http does not support timeouts at the moment ' );
409
+ }
410
+
411
+ $ this ->expectException (Neo4jException::class);
412
+
413
+ $ result = $ this ->getClient ()
414
+ ->getDriver ($ alias )
415
+ ->createSession ()
416
+ ->run (
417
+ "MATCH (n:Node) SET n.testing = 'hello' WITH * CALL apoc.util.sleep(2000000) " ,
418
+ [],
419
+ TransactionConfiguration::default ()->withTimeout (150 )
420
+ );
421
+
422
+ unset($ result );
423
+ }
424
+
379
425
/**
380
426
* @dataProvider connectionAliases
381
427
*/
You can’t perform that action at this time.
0 commit comments