Closed Bug 794078 Opened 12 years ago Closed 5 years ago

Actors should return a response promise instead of sending reply packets directly

Categories

(DevTools :: Debugger, defect, P3)

x86
macOS
defect

Tracking

(Not tracked)

RESOLVED INVALID

People

(Reporter: fitzgen, Unassigned)

References

(Blocks 1 open bug)

Details

An actor shouldn't have to know about |send| to do async, it should only have to deal in packets. If it is going to respond in an async fashion, it should return a promise. If it doesn't return anything, that should be an error.
Priority: -- → P3
There are currently three request methods in script.js that send responses via |this.conn.send| directly rather than returning a packet/promise(packet):

1. onAttach

2. onInterrupt

3. onExceptionUnwind

The reason they do this is because after they send the response, they push a new event loop.

If we tried to enter the event loop and then return the packet, we would just hang forever, so that's a no go.

Perhaps we can executeSoon-ify the entering of an event loop so it happens on the next tick after returning the packet? I don't think that would give us the guarantee that we won't receive a new packet before entering that nested event loop, though.

I think whatever fix we come up with might have to be integrated with bug 908452
Woops, onExceptionUnwind is definitely not a request method. Make that 2 request methods that use |this.conn.send| directly.
More request methods responding with |send| directly:

* gcli.js: GcliActor.prototype.execute - looks easy to port over at first glance

* tracer.js: TraceActor.prototype.onDetach - looks easy to port over at first glance
I think that is all of them.
Summary: When an actor is going to send a packet asyncly, it should return a promise of a packet, rather than calling send itself → Actors should return a response promise instead of sending reply packets directly
Blocks: dbg-server
Product: Firefox → DevTools

this is no longer relevant with the protocol work

Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.