He-Pin opened a new issue, #3105:
URL: https://github.com/apache/pekko/issues/3105
### Motivation
`IdleInject` initializes `nextDeadline` at `GraphStageLogic` construction
time (`System.nanoTime + timeout.toNanos`), not in `preStart()` or on first
`onPull()`. If materialization takes longer than the configured timeout, the
first pull triggers an immediate idle element injection even though no actual
idle period has occurred.
### Current behavior
`Timers.scala:241-249`:
```scala
override def createLogic(inheritedAttributes: Attributes): GraphStageLogic =
new TimerGraphStageLogic(shape) with StageLogging with InHandler with
OutHandler {
private var nextDeadline: Long = System.nanoTime + timeout.toNanos //
Set at construction
...
override def preStart(): Unit = pull(in) // Does not update deadline
```
### Proposed fix
Move `nextDeadline` initialization to `preStart()`:
```scala
private var nextDeadline: Long = 0L
override def preStart(): Unit = {
nextDeadline = System.nanoTime + timeout.toNanos
pull(in)
}
```
### References
- Inspired by Akka.NET
[#7881](https://github.com/akkadotnet/akka.net/pull/7881)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]