Question: I want to remove an attribute that has already been stored.  

For example , as there are users who have a 'surname',

```
GET https://graph.microsoft.com/v1.0/users/test01@test.onmicrosoft.com?$select=id,userPrincipalName,surname  

response:
{  
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users(id,userPrincipalName,surname)/$entity",  
    "id": "8e05e09b-c195-4404-87c1-2325767b66cd",  
    "userPrincipalName": "test01@test.onmicrosoft.com",  
    "surname": "ABCDEF"  
}  

```

In this case , I want to remove the 'surname'.  

Is also not removed when update is null, the value is not changed.

```
PATCH https://graph.microsoft.com/v1.0/users/test01@test.onmicrosoft.com
{
    "surname": null
}

```

It is an error to be updated in "".

```
PATCH https://graph.microsoft.com/v1.0/users/test01@test.onmicrosoft.com
{
    "surname": ""
}

response:
{
    "error": {
        "code": "Request_BadRequest",
        "message": "Invalid value specified for property 'surname' of resource 'User'.",
        "innerError": {
            "request-id": "159ef469-f527-4768-b1bd-99ffc3446e5c",
            "date": "2016-06-22T14:35:18"
        }
    }
}

```

Please tell me how to remove.

Answer: 
> 
> Could this potentially cause a stack overflow?
> 
> 
> 

No, it will not cause a stack overflow. An async callback is called when the stack is completely unwound so there is no stack buildup. 

Remember how an async operation works. The current thread of Javascript starts the async operation. That async operation is then managed by some other native code. The current thread of Javascript then runs to its completion and finishes (thus clearing the stack).

Some time later, the native code that is running the async operation sees that the operation has completed and posts an event to the Javascript event queue to call the callback for that async operation. When the JS engine is not running anything else, it will then pull that event out of the queue and process it (calling the callback). At the time it calls the callback, it will have an empty stack frame.

There will be an active scope object for the callback function, but in Javascript scopes are completely separate from the stack frame.

The only time this could be a problem is if your callback was ever called synchronously. Then, there would obviously be a stack build-up and the potential for stack overflow. But, as long as the callback is always called asynchronously (which it should be), then there is no issue.

> 
> Is there a way to refactor this code to not be recursive?
> 
> 
> 

It is a very useful design pattern in Javascript asynchronous programming to run the next iteration of something from the completion of the previous iteration and calling a function from within it is the usual way to do so. There is no reason to refactor it.
No, this won't cause a stack overflow. When you call an asynchronous function, the original function returns, so it's stack frame is freed. The callback function is called from the event handler, not from the original function.