npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-native-knotapi

v1.0.18

Published

Provide a seamless way for end users to link their merchant accounts to your mobile app.

Readme

React Native KnotAPI

Test Bridge

Please see https://docs.knotapi.com/ for installation instructions.

🚨 Critical Bridge Fixes

This version includes critical fixes to prevent crashes in React Native applications, specifically addressing bridge teardown race conditions and memory management issues.

Quick Fix Summary

  • Bridge State Management: Added lifecycle tracking to prevent events being sent to deallocated bridges
  • Close Protection: Prevents multiple close calls and double teardown scenarios
  • Delegate Safety: All delegate methods now safely ignore events when bridge is inactive
  • Exception Handling: Graceful handling of exceptions during close operations
  • Memory Management: Proper cleanup and weak reference patterns

Crash Scenarios Fixed

  • ✅ Bridge teardown race conditions
  • ✅ Events sent to deallocated bridge
  • ✅ Multiple close() calls causing double teardown
  • ✅ Memory leaks and retain cycles
  • ✅ Exception handling during close operations

Required iOS SDK Fix

CRITICAL: The iOS SDK must also be updated to make KnotSession.delegate a weak reference:

// In KnotSession.swift - REQUIRED FIX
public weak var delegate: KnotEventDelegate?

Testing

Comprehensive test suite included to verify all crash scenarios are handled:

cd ios/
./run_tests.sh

Test Options:

  • Simple Tests (No Xcode required) - Quick verification of all fixes
  • Full XCTest Suite - Comprehensive testing with mocking and edge cases
  • Crash Scenario Tests - Specific tests for crash prevention

GitHub Actions Integration

Automated testing with GitHub Actions:

  • Bridge Tests - Runs on push/PR/release, comprehensive bridge testing
  • Conditional Testing - Additional tests run on releases (iOS compatibility, documentation)

📚 Technical Details

Bridge Fixes Implementation

Files Modified:

  • ios/Knotapi.mm - Core bridge implementation with safety checks

Key Changes:

// Added properties
@property (nonatomic, assign) BOOL isBridgeActive;
@property (nonatomic, assign) BOOL isClosing;

// Added safety checks to all delegate methods
- (void)onErrorWithError:(enum KnotError)error {
    if (!self.isBridgeActive) {
        NSLog(@"KnotAPI onError: Bridge inactive, ignoring event");
        return;
    }
    // ... rest of method
}

// Added close protection
- (void)close {
    if (self.isClosing) {
        NSLog(@"KnotAPI close: Already closing, ignoring duplicate call");
        return;
    }
    self.isClosing = YES;
    // ... rest of method
}

Test Suite

Test Files:

  • ios/SimpleBridgeTest.m - Quick verification (no Xcode required)
  • ios/KnotapiTests.m - Full XCTest suite
  • ios/KnotapiCrashScenarioTests.m - Crash scenario tests
  • ios/run_tests.sh - Comprehensive test runner (includes verification)

Running Tests:

cd ios/
./run_tests.sh

GitHub Actions

Workflow: .github/workflows/test.yml

  • Triggers: Push/PR/release/manual
  • Tests: Bridge fixes, compilation, integration
  • Conditional: iOS compatibility and docs on releases

Manual Testing:

gh workflow run test.yml

🔧 Troubleshooting

iOS Build Issues

Node.js Path Issues (Homebrew Installation)

If you installed Node.js via Homebrew and encounter build errors like:

/usr/local/bin/node: No such file or directory

Solution: Create a symlink to make Node.js accessible at the expected path:

sudo ln -sf /opt/homebrew/bin/node /usr/local/bin/node

Verify the fix:

which node
# Should show: /opt/homebrew/bin/node

/usr/local/bin/node --version
# Should show your Node.js version

Test Files in Library Build

If you encounter errors like:

'XCTest/XCTest.h' file not found (in target 'react-native-knotapi' from project 'Pods')

Solution: The podspec has been updated to exclude test files from the main library build. If you're still seeing this error:

  1. Clean your build:

    cd example/ios
    rm -rf build Pods Podfile.lock
  2. Reinstall pods:

    pod install
  3. Try building again:

    cd ..
    npm run ios

General iOS Build Issues

If you encounter other iOS build issues:

  1. Clean everything:

    cd example/ios
    rm -rf build Pods Podfile.lock
    cd ..
    rm -rf node_modules
    npm install
    cd ios
    pod install
  2. Check Xcode version compatibility:

    • Ensure you're using Xcode 16.1 or later
    • Verify iOS deployment target is 15.1+
  3. Verify React Native setup:

    npx react-native doctor

Installation & Usage

Please see https://docs.knotapi.com/ for complete installation and usage instructions.