Skip to content

First interceptor in compose is not the first to be called #4241

@artur-ma

Description

@artur-ma

Bug Description

The doc states "The order of the interceptors matters. The first interceptor will be the first to be called."

> - The order of the interceptors matters. The first interceptor will be the first to be called.

Reproducible By

    const a = new Agent().compose([
      (dispatch) => {
        return (opts, handler) => {
          console.log('interceptor 1');
          return dispatch(opts, handler);
        };
      },
      (dispatch) => {
        return (opts, handler) => {
          console.log('interceptor 2');
          return dispatch(opts, handler);
        };
      },
    ]);

    a.request({
      origin: '127.0.0.1',
      path: '/',
      method: 'GET',
    });

Expected Behavior

It should print

interceptor 1
interceptor 2

but actually it prints

interceptor 2
interceptor 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocsChanges related to the documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions