Bug: User is not deleted immediately upon a successful request

There is a bug in your management API. User is not deleted upon returnining a response with status 204. For several more seconds it is still possible to fetch the user. It maybe not a problem for a common usage. It is a quite an annoying problem for testing.

How to reproduce it

  1. delete a user X (response status is 204)
  2. try to fetch the same user X
  3. user is fetched although the response should 404 NOT FOUND

Here is a test code:

// response.status === 204
await userService.deleteUser(EMAIL);
// User found!!
await userService.getUser(EMAIL); 

async getUser(email) {
    debug(`finding user with ${email}`);
    checkIsDefined(email, 'email')
    const response = await httpClient.get(this.path + `?q=email:"${email}"`)
    if(!response) return null

    if(response.data.length > 1){
      throw new Error(`Multiple results found for ${email}:${JSON.stringify(response.data)}`)

    return response.data[0]

  async deleteUser(email) {
    debug(`deleting user with email ${email}`);
    checkIsDefined(email, 'userId')

    const user = await this.getUser(email)
    if (!user) {
      debug('user not found')
      return false

    debug('Deleting user with id ' + user.user_id);

    const response = await httpClient.delete(this.path + `/${user.user_id}`)
    return response.status === 204
1 Like

It’s also not working the other way around. If you create a user and try to delete it too early for your API then the deletion won’t happen.