- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 33.6k
src: add internal binding for constructing SharedArrayBuffers #60497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Open
      
      
            Renegade334
  wants to merge
  2
  commits into
  nodejs:main
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
Renegade334:bound-sharedarraybuffer-construct
  
      
      
   
  
    
  
  
  
 
  
      
    base: main
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
                
     Open
            
            src: add internal binding for constructing SharedArrayBuffers #60497
                    Renegade334
  wants to merge
  2
  commits into
  nodejs:main
from
Renegade334:bound-sharedarraybuffer-construct
  
      
      
   
              
            
      
        
          +87
        
        
          −44
        
        
          
        
      
    
  
Conversation
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
    | Review requested: 
 | 
2705b57    to
    83074c3      
    Compare
  
    
              
                    aduh95
  
              
              approved these changes
              
                  
                    Oct 30, 2025 
                  
              
              
            
            
| Codecov Report❌ Patch coverage is  
 Additional details and impacted files@@            Coverage Diff             @@
##             main   #60497      +/-   ##
==========================================
+ Coverage   88.05%   88.57%   +0.51%     
==========================================
  Files         704      704              
  Lines      207857   207872      +15     
  Branches    39964    40048      +84     
==========================================
+ Hits       183030   184123    +1093     
+ Misses      16806    15771    -1035     
+ Partials     8021     7978      -43     
 🚀 New features to boost your workflow:
 | 
              
                    codebytere
  
              
              approved these changes
              
                  
                    Oct 31, 2025 
                  
              
              
            
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
      Labels
      
    author ready
  PRs that have at least one approval, no pending requests for changes, and a CI started. 
  
    dont-land-on-v20.x
  PRs that should not land on the v20.x-staging branch and should not be released in v20.x. 
  
    dont-land-on-v22.x
  PRs that should not land on the v22.x-staging branch and should not be released in v22.x. 
  
    lib / src
  Issues and PRs related to general changes in the lib or src directory. 
  
    needs-ci
  PRs that need a full CI run. 
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
SharedArrayBuffers are finding more and more use in core, but the flag-dependent exposure of the constructor is a permanent issue. In the common case where the constructor is available, the global is potentially user-mutable depending on when it's accessed, and in the case where the constructor isn't available, this either results in deliberately lost functionality or just straight runtime errors.
The approach here adds a utility binding to construct SABs via the V8 API, which is ubiquitously available independent of the flag state.
An alternative approach would be to use the JS global if present, and only call into C++ if absent. In reality, this method is vanishingly unlikely to ever be needed in a hot path, so the call cost isn't as much of a consideration, and using the API adds the primordial-esque safety factor.
Would supersede #60453. Does not land on v20.x or v22.x, as
MaybeNewwas added in V8 13.1.